mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 08:14:58 +01:00
Fix O(n) search on MIDI rec region update (now O(log(n)) per update, but could be O(1) with caching...)
git-svn-id: svn://localhost/ardour2/branches/3.0@5843 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
2c59ddede5
commit
86a09c58e3
3 changed files with 18 additions and 7 deletions
|
|
@ -575,12 +575,12 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
|
||||||
rect->property_x2() = xend;
|
rect->property_x2() = xend;
|
||||||
|
|
||||||
ARDOUR::BeatsFramesConverter tconv(_trackview.session(), region->position());
|
ARDOUR::BeatsFramesConverter tconv(_trackview.session(), region->position());
|
||||||
|
const MidiModel::TimeType start_beats = tconv.from(start);
|
||||||
|
|
||||||
/* draw events */
|
/* draw events */
|
||||||
MidiRegionView* mrv = (MidiRegionView*)iter->second;
|
MidiRegionView* mrv = (MidiRegionView*)iter->second;
|
||||||
|
|
||||||
// FIXME: this is offensively slow (linear search)
|
for (MidiModel::Notes::const_iterator i = data->note_lower_bound(start_beats);
|
||||||
for (MidiModel::Notes::const_iterator i = data->notes().begin();
|
|
||||||
i != data->notes().end(); ++i) {
|
i != data->notes().end(); ++i) {
|
||||||
|
|
||||||
const boost::shared_ptr<MidiRegionView::NoteType>& note = *i;
|
const boost::shared_ptr<MidiRegionView::NoteType>& note = *i;
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,8 @@ public:
|
||||||
const_iterator begin(Time t=0) const { return const_iterator(*this, t); }
|
const_iterator begin(Time t=0) const { return const_iterator(*this, t); }
|
||||||
const const_iterator& end() const { return _end_iter; }
|
const const_iterator& end() const { return _end_iter; }
|
||||||
|
|
||||||
|
typename Notes::const_iterator note_lower_bound (Time t) const;
|
||||||
|
|
||||||
bool control_to_midi_event(boost::shared_ptr< Event<Time> >& ev,
|
bool control_to_midi_event(boost::shared_ptr< Event<Time> >& ev,
|
||||||
const ControlIterator& iter) const;
|
const ControlIterator& iter) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,12 +99,10 @@ Sequence<Time>::const_iterator::const_iterator(const Sequence<Time>& seq, Time t
|
||||||
|
|
||||||
seq.read_lock();
|
seq.read_lock();
|
||||||
|
|
||||||
// Find first note which begins after t
|
// Find first note which begins at or after t
|
||||||
boost::shared_ptr< Note<Time> > search_note(new Note<Time>(0, t, 0, 0, 0));
|
_note_iter = seq.note_lower_bound(t);
|
||||||
_note_iter = seq.notes().lower_bound(search_note);
|
|
||||||
assert(_note_iter == seq.notes().end() || (*_note_iter)->time() >= t);
|
|
||||||
|
|
||||||
// Find first sysex event after t
|
// Find first sysex event at or after t
|
||||||
for (typename Sequence<Time>::SysExes::const_iterator i = seq.sysexes().begin();
|
for (typename Sequence<Time>::SysExes::const_iterator i = seq.sysexes().begin();
|
||||||
i != seq.sysexes().end(); ++i) {
|
i != seq.sysexes().end(); ++i) {
|
||||||
if ((*i)->time() >= t) {
|
if ((*i)->time() >= t) {
|
||||||
|
|
@ -776,6 +774,17 @@ Sequence<Time>::set_notes (const Sequence<Time>::Notes& n)
|
||||||
_notes = n;
|
_notes = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return the earliest note with time >= t */
|
||||||
|
template<typename Time>
|
||||||
|
typename Sequence<Time>::Notes::const_iterator
|
||||||
|
Sequence<Time>::note_lower_bound (Time t) const
|
||||||
|
{
|
||||||
|
boost::shared_ptr< Note<Time> > search_note(new Note<Time>(0, t, 0, 0, 0));
|
||||||
|
typename Sequence<Time>::Notes::const_iterator i = _notes.lower_bound(search_note);
|
||||||
|
assert(i == _notes.end() || (*i)->time() >= t);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
template class Sequence<Evoral::MusicalTime>;
|
template class Sequence<Evoral::MusicalTime>;
|
||||||
|
|
||||||
} // namespace Evoral
|
} // namespace Evoral
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue