diff options
author | Florian Jung <flo@windfisch.org> | 2013-09-18 23:54:35 +0200 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2013-09-18 23:54:35 +0200 |
commit | b3fc353a09496ee0aea7099d72e6963f4c2fc774 (patch) | |
tree | 83ab91e988c59076d81ebddc09e8ff274dee8af5 /muse2/muse/steprec.cpp | |
parent | 48a93993cfce160fb7d4cf0b67b4b77e22db19e5 (diff) | |
parent | 85a51421d44f3893a1010f77e0418caf6be70235 (diff) |
Merge branch 'audiomsg_overhaul' (nonshared eventlists and more)
This introduces the following changes:
- Clone Parts no more share their eventlist. Instead, all changes
made to one clone are replicated to the other clones' eventlists
- audio/song->msg{Add,Delete,Change}{Part,Event,Track} have been
replaced by the corresponding UndoOp operations.
- Enforcing of const-correctness: No GUI code may ever gain
writable access to audio/midi/song data structures. Access
must *always* go through applyOperationGroup. This is now
enforced.
- Removed a bunch of DELETETHIS or REMOVE or otherwise commented
out code
- Removed dead code
- Removed unused Audio Messages (that should go through applyOpGroup
anyway.)
Diffstat (limited to 'muse2/muse/steprec.cpp')
-rw-r--r-- | muse2/muse/steprec.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/muse2/muse/steprec.cpp b/muse2/muse/steprec.cpp index 723fe650..44da5a7e 100644 --- a/muse2/muse/steprec.cpp +++ b/muse2/muse/steprec.cpp @@ -55,7 +55,7 @@ void StepRec::timeout() } } -void StepRec::record(Part* part, int pitch, int len, int step, int velo, bool ctrl, bool shift, int incoming_pitch) +void StepRec::record(const Part* part, int pitch, int len, int step, int velo, bool ctrl, bool shift, int incoming_pitch) { unsigned tick = MusEGlobal::song->cpos(); unsigned lasttick=0; @@ -76,12 +76,12 @@ void StepRec::record(Part* part, int pitch, int len, int step, int velo, bool ct chord_timer->stop(); // extend len of last note? - EventList* events = part->events(); + const EventList& events = part->events(); if (ctrl) { - for (iEvent i = events->begin(); i != events->end(); ++i) + for (ciEvent i = events.begin(); i != events.end(); ++i) { - Event ev = i->second; + const Event& ev = i->second; if (ev.isNote() && ev.pitch() == pitch && ((ev.tick() + ev.lenTick() + part->tick()) == tick)) { Event e = ev.clone(); @@ -106,13 +106,13 @@ void StepRec::record(Part* part, int pitch, int len, int step, int velo, bool ct // if we would find a note after part->lenTick(), the above "if" // avoids this. this has to be avoided because then part->hasHiddenEvents() is true // which results in forbidding any action beyond its end - EventRange range = events->equal_range(tick - part->tick()); - for (iEvent i = range.first; i != range.second; ++i) + EventRange range = events.equal_range(tick - part->tick()); + for (ciEvent i = range.first; i != range.second; ++i) { - Event ev = i->second; + const Event& ev = i->second; if (ev.isNote() && ev.pitch() == pitch) { - MusEGlobal::audio->msgDeleteEvent(ev, part, true, false, false); + MusEGlobal::song->applyOperation(UndoOp(UndoOp::DeleteEvent,ev, part, true,true)); if (!shift) { @@ -161,18 +161,18 @@ void StepRec::record(Part* part, int pitch, int len, int step, int velo, bool ct // extend len of last note(s) using std::set; - set<Event*> extend_set; - EventList* events = part->events(); - for (iEvent i = events->begin(); i != events->end(); ++i) + set<const Event*> extend_set; + const EventList& events = part->events(); + for (ciEvent i = events.begin(); i != events.end(); ++i) { - Event& ev = i->second; + const Event& ev = i->second; if (ev.isNote() && note_held_down[ev.pitch()] && ((ev.tick() + ev.lenTick() + part->tick()) == tick)) extend_set.insert(&ev); } - for (set<Event*>::iterator it=extend_set.begin(); it!=extend_set.end(); it++) + for (set<const Event*>::iterator it=extend_set.begin(); it!=extend_set.end(); it++) { - Event& ev=**it; + const Event& ev=**it; Event e = ev.clone(); e.setLenTick(ev.lenTick() + len); operations.push_back(UndoOp(UndoOp::ModifyEvent,e, ev, part, false, false)); |