From 66f18914b21837b0d4087d1d5dfff3d654cc3ef7 Mon Sep 17 00:00:00 2001 From: André Nusser Date: Thu, 15 Oct 2015 15:36:17 +0200 Subject: Split transpose in MidiModel into two functions. --- libs/ardour/ardour/midi_model.h | 1 + libs/ardour/midi_model.cc | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h index b2e018ca3b..80ae71f206 100644 --- a/libs/ardour/ardour/midi_model.h +++ b/libs/ardour/ardour/midi_model.h @@ -287,6 +287,7 @@ public: boost::shared_ptr 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& active_notes() { return _active_notes; } diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index fd08428a68..5997c5b548 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -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); } } -- cgit v1.2.3