diff options
-rw-r--r-- | libs/evoral/evoral/Sequence.hpp | 8 | ||||
-rw-r--r-- | libs/evoral/src/Sequence.cpp | 40 |
2 files changed, 45 insertions, 3 deletions
diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index e2e92385aa..dbc04d619b 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -179,7 +179,7 @@ public: OverlapPitchResolution overlap_pitch_resolution() const { return _overlap_pitch_resolution; } void set_overlap_pitch_resolution(OverlapPitchResolution opr); - void set_notes (const Sequence<Time>::Notes& n); + void set_notes (const typename Sequence<Time>::Notes& n); typedef boost::shared_ptr< Event<Time> > SysExPtr; typedef boost::shared_ptr<const Event<Time> > constSysExPtr; @@ -269,10 +269,16 @@ public: const const_iterator& end() const { return _end_iter; } + // CONST iterator implementations (x3) typename Notes::const_iterator note_lower_bound (Time t) const; typename PatchChanges::const_iterator patch_change_lower_bound (Time t) const; typename SysExes::const_iterator sysex_lower_bound (Time t) const; + // NON-CONST iterator implementations (x3) + typename Notes::iterator note_lower_bound (Time t); + typename PatchChanges::iterator patch_change_lower_bound (Time t); + typename SysExes::iterator sysex_lower_bound (Time t); + bool control_to_midi_event(boost::shared_ptr< Event<Time> >& ev, const ControlIterator& iter) const; diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp index 204ef58f33..7084a90491 100644 --- a/libs/evoral/src/Sequence.cpp +++ b/libs/evoral/src/Sequence.cpp @@ -1201,11 +1201,13 @@ Sequence<Time>::overlaps_unlocked (const NotePtr& note, const NotePtr& without) template<typename Time> void -Sequence<Time>::set_notes (const Sequence<Time>::Notes& n) +Sequence<Time>::set_notes (const typename Sequence<Time>::Notes& n) { _notes = n; } +// CONST iterator implementations (x3) + /** Return the earliest note with time >= t */ template<typename Time> typename Sequence<Time>::Notes::const_iterator @@ -1239,6 +1241,41 @@ Sequence<Time>::sysex_lower_bound (Time t) const return i; } +// NON-CONST iterator implementations (x3) + +/** Return the earliest note with time >= t */ +template<typename Time> +typename Sequence<Time>::Notes::iterator +Sequence<Time>::note_lower_bound (Time t) +{ + NotePtr search_note(new Note<Time>(0, t, 0, 0, 0)); + typename Sequence<Time>::Notes::iterator i = _notes.lower_bound(search_note); + assert(i == _notes.end() || (*i)->time() >= t); + return i; +} + +/** Return the earliest patch change with time >= t */ +template<typename Time> +typename Sequence<Time>::PatchChanges::iterator +Sequence<Time>::patch_change_lower_bound (Time t) +{ + PatchChangePtr search (new PatchChange<Time> (t, 0, 0, 0)); + typename Sequence<Time>::PatchChanges::iterator i = _patch_changes.lower_bound (search); + assert (i == _patch_changes.end() || musical_time_greater_or_equal_to ((*i)->time(), t)); + return i; +} + +/** Return the earliest sysex with time >= t */ +template<typename Time> +typename Sequence<Time>::SysExes::iterator +Sequence<Time>::sysex_lower_bound (Time t) +{ + SysExPtr search (new Event<Time> (0, t)); + typename Sequence<Time>::SysExes::iterator i = _sysexes.lower_bound (search); + assert (i == _sysexes.end() || (*i)->time() >= t); + return i; +} + template<typename Time> void Sequence<Time>::get_notes (Notes& n, NoteOperator op, uint8_t val, int chan_mask) const @@ -1393,4 +1430,3 @@ Sequence<Time>::dump (ostream& str) const template class Sequence<Evoral::MusicalTime>; } // namespace Evoral - |