try not thinning when loading old-school automation lists
[ardour.git] / libs / ardour / midi_model.cc
index ce357dcd3682ea1f34ce8f860b54b724b9a9a340..a914a0d8873f55942942d93db825c600a9b6737f 100644 (file)
 
 */
 
-#include <set>
-#include <iostream>
 #include <algorithm>
+#include <iostream>
+#include <set>
 #include <stdexcept>
 #include <stdint.h>
-#include "pbd/error.h"
-#include "pbd/enumwriter.h"
+
 #include "pbd/compose.h"
+#include "pbd/enumwriter.h"
+#include "pbd/error.h"
+
+#include "evoral/Control.hpp"
+
 #include "midi++/events.h"
 
+#include "ardour/automation_control.h"
+#include "ardour/midi_automation_list_binder.h"
 #include "ardour/midi_model.h"
 #include "ardour/midi_source.h"
 #include "ardour/midi_state_tracker.h"
-#include "ardour/smf_source.h"
-#include "ardour/types.h"
 #include "ardour/session.h"
-#include "ardour/midi_automation_list_binder.h"
+#include "ardour/types.h"
 
 #include "i18n.h"
 
@@ -503,8 +507,8 @@ MidiModel::NoteDiffCommand::unmarshal_note (XMLNode *xml_note)
        unsigned int note;
        XMLProperty* prop;
        unsigned int channel;
-       unsigned int time;
-       unsigned int length;
+       MidiModel::TimeType time;
+       MidiModel::TimeType length;
        unsigned int velocity;
        gint id;
 
@@ -1863,7 +1867,7 @@ MidiModel::midi_source ()
        return _midi_source.lock ();
 }
 
-/** Moves notes, controllers and sys-ex to insert silence at the start of the model.
+/** Moves notes, patch changes, controllers and sys-ex to insert silence at the start of the model.
  *  Adds commands to the session's current undo stack to reflect the movements.
  */
 void
@@ -1884,6 +1888,18 @@ MidiModel::insert_silence_at_start (TimeType t)
                apply_command_as_subcommand (s->session(), c);
        }
 
+       /* Patch changes */
+
+       if (!patch_changes().empty ()) {
+               PatchChangeDiffCommand* c = new_patch_change_diff_command ("insert silence");
+
+               for (PatchChanges::const_iterator i = patch_changes().begin(); i != patch_changes().end(); ++i) {
+                       c->change_time (*i, (*i)->time() + t);
+               }
+
+               apply_command_as_subcommand (s->session(), c);
+       }
+
        /* Controllers */
 
        for (Controls::iterator i = controls().begin(); i != controls().end(); ++i) {
@@ -1946,3 +1962,11 @@ MidiModel::transpose (TimeType from, TimeType to, int semitones)
 
        apply_command (s->session (), c);
 }
+
+void
+MidiModel::control_list_marked_dirty ()
+{
+       AutomatableSequence<Evoral::MusicalTime>::control_list_marked_dirty ();
+       
+       ContentsChanged (); /* EMIT SIGNAL */
+}