diff options
Diffstat (limited to 'libs/evoral/src/Sequence.cpp')
-rw-r--r-- | libs/evoral/src/Sequence.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp index 3098d0339d..14e3b65f37 100644 --- a/libs/evoral/src/Sequence.cpp +++ b/libs/evoral/src/Sequence.cpp @@ -63,7 +63,7 @@ template<typename Time> Sequence<Time>::const_iterator::const_iterator() : _seq(NULL) , _event(boost::shared_ptr< Event<Time> >(new Event<Time>())) - , _active_patch_change_message (0) + , _active_patch_change_message (NO_EVENT) , _type(NIL) , _is_end(true) , _control_iter(_control_iters.end()) @@ -191,7 +191,7 @@ Sequence<Time>::const_iterator::const_iterator(const Sequence<Time>& // Allocate a new event for storing the current event in MIDI format _event = boost::shared_ptr< Event<Time> >( - new Event<Time>(0, Time(), 4, NULL, true)); + new Event<Time>(NO_EVENT, Time(), 4, NULL, true)); // Set event from chosen sub-iterator set_event(); @@ -515,9 +515,8 @@ Sequence<Time>::Sequence(const Sequence<Time>& other) assert(! _end_iter._lock); } -/** Write the controller event pointed to by \a iter to \a ev. - * The buffer of \a ev will be allocated or resized as necessary. - * The event_type of \a ev should be set to the expected output type. +/** Write the controller event pointed to by `iter` to `ev`. + * The buffer of `ev` will be allocated or resized as necessary. * \return true on success */ template<typename Time> @@ -527,15 +526,14 @@ Sequence<Time>::control_to_midi_event( const ControlIterator& iter) const { assert(iter.list.get()); - const uint32_t event_type = iter.list->parameter().type(); // initialize the event pointer with a new event, if necessary if (!ev) { - ev = boost::shared_ptr< Event<Time> >(new Event<Time>(event_type, Time(), 3, NULL, true)); + ev = boost::shared_ptr< Event<Time> >(new Event<Time>(NO_EVENT, Time(), 3, NULL, true)); } - uint8_t midi_type = _type_map.parameter_midi_type(iter.list->parameter()); - ev->set_event_type(_type_map.midi_event_type(midi_type)); + const uint8_t midi_type = _type_map.parameter_midi_type(iter.list->parameter()); + ev->set_event_type(MIDI_EVENT); ev->set_id(-1); switch (midi_type) { case MIDI_CMD_CONTROL: @@ -933,23 +931,28 @@ Sequence<Time>::append(const Event<Time>& ev, event_id_t evid) _bank[ev.channel()] |= ev.cc_value(); } } else if (ev.is_cc()) { + const ParameterType ptype = _type_map.midi_parameter_type(ev.buffer(), ev.size()); append_control_unlocked( - Parameter(ev.event_type(), ev.channel(), ev.cc_number()), + Parameter(ptype, ev.channel(), ev.cc_number()), ev.time(), ev.cc_value(), evid); } else if (ev.is_pgm_change()) { /* write a patch change with this program change and any previously set-up bank number */ - append_patch_change_unlocked (PatchChange<Time> (ev.time(), ev.channel(), ev.pgm_number(), _bank[ev.channel()]), evid); + append_patch_change_unlocked ( + PatchChange<Time> (ev.time(), ev.channel(), + ev.pgm_number(), _bank[ev.channel()]), evid); } else if (ev.is_pitch_bender()) { + const ParameterType ptype = _type_map.midi_parameter_type(ev.buffer(), ev.size()); append_control_unlocked( - Parameter(ev.event_type(), ev.channel()), + Parameter(ptype, ev.channel()), ev.time(), double ((0x7F & ev.pitch_bender_msb()) << 7 | (0x7F & ev.pitch_bender_lsb())), evid); } else if (ev.is_poly_pressure()) { append_control_unlocked (Parameter (ev.event_type(), ev.channel(), ev.poly_note()), ev.time(), ev.poly_pressure(), evid); } else if (ev.is_channel_pressure()) { + const ParameterType ptype = _type_map.midi_parameter_type(ev.buffer(), ev.size()); append_control_unlocked( - Parameter(ev.event_type(), ev.channel()), + Parameter(ptype, ev.channel()), ev.time(), ev.channel_pressure(), evid); } else if (!_type_map.type_is_midi(ev.event_type())) { printf("WARNING: Sequence: Unknown event type %X: ", ev.event_type()); @@ -1215,7 +1218,7 @@ template<typename Time> typename Sequence<Time>::SysExes::const_iterator Sequence<Time>::sysex_lower_bound (Time t) const { - SysExPtr search (new Event<Time> (0, t)); + SysExPtr search (new Event<Time> (NO_EVENT, t)); typename Sequence<Time>::SysExes::const_iterator i = _sysexes.lower_bound (search); assert (i == _sysexes.end() || (*i)->time() >= t); return i; @@ -1250,7 +1253,7 @@ template<typename Time> typename Sequence<Time>::SysExes::iterator Sequence<Time>::sysex_lower_bound (Time t) { - SysExPtr search (new Event<Time> (0, t)); + SysExPtr search (new Event<Time> (NO_EVENT, t)); typename Sequence<Time>::SysExes::iterator i = _sysexes.lower_bound (search); assert (i == _sysexes.end() || (*i)->time() >= t); return i; |