summaryrefslogtreecommitdiff
path: root/muse2/muse/eventlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'muse2/muse/eventlist.cpp')
-rw-r--r--muse2/muse/eventlist.cpp53
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;
+ }
}
//---------------------------------------------------------