diff options
author | Tim E. Real <termtech@rogers.com> | 2012-09-05 00:53:55 +0000 |
---|---|---|
committer | Tim E. Real <termtech@rogers.com> | 2012-09-05 00:53:55 +0000 |
commit | f54d0539f6fd26f9b326ddb6761e0a6c296ca6dc (patch) | |
tree | e003a3320d1cd7a81eacd46cdd1ccce7c7cb90e0 /muse2/muse | |
parent | 4077e6b734ec46bd802526db654b389df983c498 (diff) |
Fix for forum topic "Ordering of simultaneous events".
Methods EventList::add() and ::move() now sort all same-time notes AFTER controllers.
Diffstat (limited to 'muse2/muse')
-rw-r--r-- | muse2/muse/eventlist.cpp | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/muse2/muse/eventlist.cpp b/muse2/muse/eventlist.cpp index 66780adb..25acd5a8 100644 --- a/muse2/muse/eventlist.cpp +++ b/muse2/muse/eventlist.cpp @@ -74,11 +74,29 @@ iEvent EventList::add(Event& event) // Note that in a med file, the tempo list is loaded AFTER all the tracks. // There was a bug that all the wave events' tick values were not correct, // since they were computed BEFORE the tempo map was loaded. +// REMOVE Tim. Original +// if(event.type() == Wave) +// return std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (event.frame(), event)); +// else +// +// return std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (event.tick(), event)); + if(event.type() == Wave) - return std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (event.frame(), event)); + return insert(std::pair<const unsigned, Event> (event.frame(), event)); + + unsigned key = event.tick(); + if(event.type() == Note) // Place notes after controllers. + { + iEvent i = upper_bound(key); + return insert(i, std::pair<const unsigned, Event> (key, event)); + } else - - return std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (event.tick(), event)); + { + iEvent i = lower_bound(key); + while(i != end() && i->first == key && i->second.type() != Note) + ++i; + return insert(i, std::pair<const unsigned, Event> (key, event)); + } } //--------------------------------------------------------- @@ -90,12 +108,33 @@ void EventList::move(Event& event, unsigned tick) iEvent i = find(event); erase(i); - // Added by T356. +// REMOVE Tim. Original. +// if(event.type() == Wave) +// std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (MusEGlobal::tempomap.tick2frame(tick), event)); +// else +// +// std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (tick, event)); + if(event.type() == Wave) - std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (MusEGlobal::tempomap.tick2frame(tick), event)); - else + { + insert(std::pair<const unsigned, Event> (MusEGlobal::tempomap.tick2frame(tick), event)); + return; + } - std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (tick, event)); + if(event.type() == Note) // Place notes after controllers. + { + iEvent i = upper_bound(tick); + insert(i, std::pair<const unsigned, Event> (tick, event)); + return; + } + else + { + iEvent i = lower_bound(tick); + while(i != end() && i->first == tick && i->second.type() != Note) + ++i; + insert(i, std::pair<const unsigned, Event> (tick, event)); + return; + } } //--------------------------------------------------------- |