diff options
author | David Robillard <d@drobilla.net> | 2016-11-07 05:14:55 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-12-03 15:28:19 -0500 |
commit | 398a318934769dae51efe972f7ffdefc52ea2963 (patch) | |
tree | 5b68a8fac44f0c154e7e00fd45d9e7f2c16e35fb /libs/ardour/smf_source.cc | |
parent | bfbc4566ad82573a57e1ec84d583f308ee35eef0 (diff) |
Fix event type and parameter type confusion
I'm not sure if this is really the best way to do event types (should it
just be a completely static enum in evoral, or completely dynamic and
provided by the type map, or a mix like currently?), but previously the
event type was frequently set to either total garbage, or parameter
types, which are a different thing.
This fixes all those cases, and makes Evoral::EventType an enum so the
compiler will warn about implicit conversions from int.
Diffstat (limited to 'libs/ardour/smf_source.cc')
-rw-r--r-- | libs/ardour/smf_source.cc | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index bcd3e43749..6a05ab706d 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -231,7 +231,6 @@ SMFSource::read_unlocked (const Lock& lock, // Output parameters for read_event (which will allocate scratch in buffer as needed) uint32_t ev_delta_t = 0; - uint32_t ev_type = 0; uint32_t ev_size = 0; uint8_t* ev_buffer = 0; @@ -277,10 +276,8 @@ SMFSource::read_unlocked (const Lock& lock, continue; } - ev_type = midi_parameter_type(ev_buffer[0]); - - DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF read_unlocked delta %1, time %2, buf[0] %3, type %4\n", - ev_delta_t, time, ev_buffer[0], ev_type)); + DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF read_unlocked delta %1, time %2, buf[0] %3\n", + ev_delta_t, time, ev_buffer[0])); assert(time >= start_ticks); @@ -295,7 +292,7 @@ SMFSource::read_unlocked (const Lock& lock, if (ev_frame_time < start + duration) { if (!filter || !filter->filter(ev_buffer, ev_size)) { - destination.write (ev_frame_time, ev_type, ev_size, ev_buffer); + destination.write (ev_frame_time, Evoral::MIDI_EVENT, ev_size, ev_buffer); if (tracker) { tracker->track(ev_buffer); } @@ -377,7 +374,7 @@ SMFSource::write_unlocked (const Lock& lock, time -= position; ev.set(buf, size, time); - ev.set_event_type(midi_parameter_type(ev.buffer()[0])); + ev.set_event_type(Evoral::MIDI_EVENT); ev.set_id(Evoral::next_event_id()); if (!(ev.is_channel_event() || ev.is_smf_meta_event() || ev.is_sysex())) { @@ -674,7 +671,6 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload if (!have_event_id) { event_id = Evoral::next_event_id(); } - const uint32_t event_type = midi_parameter_type(buf[0]); const Evoral::Beats event_time = Evoral::Beats::ticks_at_rate(time, ppqn()); #ifndef NDEBUG std::string ss; @@ -685,13 +681,13 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload ss += b; } - DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF %7 load model delta %1, time %2, size %3 buf %4, type %5 id %6\n", - delta_t, time, size, ss , event_type, event_id, name())); + DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF %7 load model delta %1, time %2, size %3 buf %4, id %6\n", + delta_t, time, size, ss, event_id, name())); #endif eventlist.push_back(make_pair ( new Evoral::Event<Evoral::Beats> ( - event_type, event_time, + Evoral::MIDI_EVENT, event_time, size, buf, true) , event_id)); |