Split transpose in MidiModel into two functions.
authorAndré Nusser <andre.nusser@googlemail.com>
Thu, 15 Oct 2015 13:36:17 +0000 (15:36 +0200)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 18 Oct 2015 02:12:54 +0000 (22:12 -0400)
libs/ardour/ardour/midi_model.h
libs/ardour/midi_model.cc

index b2e018ca3b4ac7f1ca67ff64208e534a8ea49011..80ae71f2060e9b1a2bab8d7356ee92d2d55b497c 100644 (file)
@@ -287,6 +287,7 @@ public:
        boost::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
 
        void insert_silence_at_start (TimeType);
+       void transpose (NoteDiffCommand *, const NotePtr, int);
        void transpose (TimeType, TimeType, int);
 
        std::set<WeakNotePtr>& active_notes() { return _active_notes; }
index fd08428a68d0a06b8bb1a72303d7943df0c26a58..5997c5b548b3d2525e70df116954f8b878adb5f2 100644 (file)
@@ -1983,6 +1983,20 @@ MidiModel::insert_silence_at_start (TimeType t)
        }
 }
 
+void
+MidiModel::transpose (NoteDiffCommand* c, const NotePtr note_ptr, int semitones)
+{
+       int new_note = note_ptr->note() + semitones;
+
+       if (new_note < 0) {
+               new_note = 0;
+       } else if (new_note > 127) {
+               new_note = 127;
+       }
+
+       c->change (note_ptr, NoteDiffCommand::NoteNumber, (uint8_t) new_note);
+}
+
 /** Transpose notes in a time range by a given number of semitones.  Notes
  *  will be clamped at 0 and 127 if the transposition would make them exceed
  *  that range.
@@ -2007,16 +2021,7 @@ MidiModel::transpose (TimeType from, TimeType to, int semitones)
 
                } else if ((*i)->time() >= from) {
 
-                       int new_note = (*i)->note() + semitones;
-
-                       if (new_note < 0) {
-                               new_note = 0;
-                       } else if (new_note > 127) {
-                               new_note = 127;
-                       }
-
-                       c->change (*i, NoteDiffCommand::NoteNumber, (uint8_t) new_note);
-
+                       transpose (c, *i, semitones);
                }
        }