summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-11-07 05:14:55 -0500
committerDavid Robillard <d@drobilla.net>2016-12-03 15:28:19 -0500
commit398a318934769dae51efe972f7ffdefc52ea2963 (patch)
tree5b68a8fac44f0c154e7e00fd45d9e7f2c16e35fb /libs/ardour
parentbfbc4566ad82573a57e1ec84d583f308ee35eef0 (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')
-rw-r--r--libs/ardour/ardour/event_type_map.h4
-rw-r--r--libs/ardour/ardour/midi_buffer.h7
-rw-r--r--libs/ardour/async_midi_port.cc2
-rw-r--r--libs/ardour/event_type_map.cc6
-rw-r--r--libs/ardour/import.cc2
-rw-r--r--libs/ardour/midi_buffer.cc2
-rw-r--r--libs/ardour/midi_diskstream.cc2
-rw-r--r--libs/ardour/midi_state_tracker.cc6
-rw-r--r--libs/ardour/midi_track.cc5
-rw-r--r--libs/ardour/smf_source.cc18
10 files changed, 25 insertions, 29 deletions
diff --git a/libs/ardour/ardour/event_type_map.h b/libs/ardour/ardour/event_type_map.h
index d7adfa8f62..b3aa05ee78 100644
--- a/libs/ardour/ardour/event_type_map.h
+++ b/libs/ardour/ardour/event_type_map.h
@@ -43,7 +43,9 @@ public:
bool type_is_midi(uint32_t type) const;
uint8_t parameter_midi_type(const Evoral::Parameter& param) const;
- uint32_t midi_event_type(uint8_t status) const;
+
+ Evoral::ParameterType midi_parameter_type(const uint8_t* buf, uint32_t len) const;
+
Evoral::ControlList::InterpolationStyle interpolation_of(const Evoral::Parameter& param);
Evoral::Parameter from_symbol(const std::string& str) const;
diff --git a/libs/ardour/ardour/midi_buffer.h b/libs/ardour/ardour/midi_buffer.h
index 1b0bf2a151..cc48e28d61 100644
--- a/libs/ardour/ardour/midi_buffer.h
+++ b/libs/ardour/ardour/midi_buffer.h
@@ -20,8 +20,9 @@
#ifndef __ardour_midi_buffer_h__
#define __ardour_midi_buffer_h__
-#include "evoral/midi_util.h"
#include "evoral/EventSink.hpp"
+#include "evoral/midi_util.h"
+#include "evoral/types.hpp"
#include "midi++/event.h"
@@ -93,7 +94,7 @@ public:
uint8_t* ev_start = buffer->_data + offset + sizeof(TimeType);
int event_size = Evoral::midi_event_size(ev_start);
assert(event_size >= 0);
- return EventType(midi_parameter_type(*ev_start),
+ return EventType(Evoral::MIDI_EVENT,
*(reinterpret_cast<TimeType*>((uintptr_t)(buffer->_data + offset))),
event_size, ev_start);
}
@@ -166,8 +167,6 @@ public:
return iterator (*this, i.offset);
}
- uint8_t* data() const { return _data; }
-
/**
* returns true if the message with the second argument as its MIDI
* status byte should preceed the message with the first argument as
diff --git a/libs/ardour/async_midi_port.cc b/libs/ardour/async_midi_port.cc
index ce8ab40a01..f7147676b0 100644
--- a/libs/ardour/async_midi_port.cc
+++ b/libs/ardour/async_midi_port.cc
@@ -143,7 +143,7 @@ AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes)
if (!have_timer) {
when += (*b).time();
}
- input_fifo.write (when, (Evoral::EventType) 0, (*b).size(), (*b).buffer());
+ input_fifo.write (when, Evoral::NO_EVENT, (*b).size(), (*b).buffer());
}
if (!mb.empty()) {
diff --git a/libs/ardour/event_type_map.cc b/libs/ardour/event_type_map.cc
index 87fe4bc6e1..ca7b51eb27 100644
--- a/libs/ardour/event_type_map.cc
+++ b/libs/ardour/event_type_map.cc
@@ -62,10 +62,10 @@ EventTypeMap::parameter_midi_type(const Evoral::Parameter& param) const
return ARDOUR::parameter_midi_type((AutomationType)param.type());
}
-uint32_t
-EventTypeMap::midi_event_type(uint8_t status) const
+Evoral::ParameterType
+EventTypeMap::midi_parameter_type(const uint8_t* buf, uint32_t len) const
{
- return (uint32_t)ARDOUR::midi_parameter_type(status);
+ return (uint32_t)ARDOUR::midi_parameter_type(buf[0]);
}
Evoral::ControlList::InterpolationStyle
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc
index 36dc48e651..d441494ad7 100644
--- a/libs/ardour/import.cc
+++ b/libs/ardour/import.cc
@@ -418,7 +418,7 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status,
smfs->append_event_beats(
source_lock,
Evoral::Event<Evoral::Beats>(
- 0,
+ Evoral::MIDI_EVENT,
Evoral::Beats::ticks_at_rate(t, source->ppqn()),
size,
buf));
diff --git a/libs/ardour/midi_buffer.cc b/libs/ardour/midi_buffer.cc
index 652be5290c..adad9c35dc 100644
--- a/libs/ardour/midi_buffer.cc
+++ b/libs/ardour/midi_buffer.cc
@@ -85,7 +85,7 @@ MidiBuffer::copy(MidiBuffer const * const copy)
{
assert(_capacity >= copy->size ());
_size = copy->size ();
- memcpy(_data, copy->data(), _size);
+ memcpy(_data, copy->_data, _size);
}
diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc
index 22a3df1145..675d1db0bf 100644
--- a/libs/ardour/midi_diskstream.cc
+++ b/libs/ardour/midi_diskstream.cc
@@ -445,7 +445,7 @@ MidiDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t
}
if (!filter || !filter->filter(ev.buffer(), ev.size())) {
- _capture_buf->write(event_time, ev.type(), ev.size(), ev.buffer());
+ _capture_buf->write(event_time, ev.event_type(), ev.size(), ev.buffer());
}
}
g_atomic_int_add(const_cast<gint*>(&_frames_pending_write), nframes);
diff --git a/libs/ardour/midi_state_tracker.cc b/libs/ardour/midi_state_tracker.cc
index 17ecd10e94..4374c06463 100644
--- a/libs/ardour/midi_state_tracker.cc
+++ b/libs/ardour/midi_state_tracker.cc
@@ -123,7 +123,7 @@ MidiStateTracker::resolve_notes (MidiBuffer &dst, framepos_t time)
while (_active_notes[note + 128 * channel]) {
uint8_t buffer[3] = { ((uint8_t) (MIDI_CMD_NOTE_OFF | channel)), uint8_t (note), 0 };
Evoral::Event<MidiBuffer::TimeType> noteoff
- (MIDI_CMD_NOTE_OFF, time, 3, buffer, false);
+ (Evoral::MIDI_EVENT, time, 3, buffer, false);
/* note that we do not care about failure from
push_back() ... should we warn someone ?
*/
@@ -157,7 +157,7 @@ MidiStateTracker::resolve_notes (Evoral::EventSink<framepos_t> &dst, framepos_t
/* note that we do not care about failure from
write() ... should we warn someone ?
*/
- dst.write (time, midi_parameter_type (buf[0]), 3, buf);
+ dst.write (time, Evoral::MIDI_EVENT, 3, buf);
_active_notes[note + 128 * channel]--;
DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1: EVS-resolved note %2/%3 at %4\n",
this, (int) note, (int) channel, time));
@@ -181,7 +181,7 @@ MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock,
for (int channel = 0; channel < 16; ++channel) {
for (int note = 0; note < 128; ++note) {
while (_active_notes[note + 128 * channel]) {
- Evoral::Event<Evoral::Beats> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true);
+ Evoral::Event<Evoral::Beats> ev (Evoral::MIDI_EVENT, time, 3, 0, true);
ev.set_type (MIDI_CMD_NOTE_OFF);
ev.set_channel (channel);
ev.set_note (note);
diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc
index 69291f1cce..c17bc916d9 100644
--- a/libs/ardour/midi_track.cc
+++ b/libs/ardour/midi_track.cc
@@ -557,7 +557,7 @@ MidiTrack::push_midi_input_to_step_edit_ringbuffer (framecnt_t nframes)
if (ev.is_note_on()) {
/* we don't care about the time for this purpose */
- _step_edit_ring_buffer.write (0, ev.type(), ev.size(), ev.buffer());
+ _step_edit_ring_buffer.write (0, ev.event_type(), ev.size(), ev.buffer());
}
}
}
@@ -689,8 +689,7 @@ MidiTrack::write_immediate_event(size_t size, const uint8_t* buf)
cerr << "WARNING: Ignoring illegal immediate MIDI event" << endl;
return false;
}
- const uint32_t type = midi_parameter_type(buf[0]);
- return (_immediate_events.write (0, type, size, buf) == size);
+ return (_immediate_events.write (0, Evoral::MIDI_EVENT, size, buf) == size);
}
void
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));