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/evoral/test | |
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/evoral/test')
-rw-r--r-- | libs/evoral/test/SMFTest.cpp | 2 | ||||
-rw-r--r-- | libs/evoral/test/SequenceTest.cpp | 6 | ||||
-rw-r--r-- | libs/evoral/test/SequenceTest.hpp | 15 |
3 files changed, 12 insertions, 11 deletions
diff --git a/libs/evoral/test/SMFTest.cpp b/libs/evoral/test/SMFTest.cpp index 0907cdc2f5..108052c98f 100644 --- a/libs/evoral/test/SMFTest.cpp +++ b/libs/evoral/test/SMFTest.cpp @@ -59,7 +59,7 @@ SMFTest::takeFiveTest () if (ret > 0) { // didn't skip (meta) event //cerr << "read smf event type " << hex << int(buf[0]) << endl; ev.set_time(Evoral::Beats::ticks_at_rate(time, smf.ppqn())); - ev.set_event_type(type_map->midi_event_type(buf[0])); + ev.set_event_type(Evoral::MIDI_EVENT); seq->append(ev, next_event_id ()); } } diff --git a/libs/evoral/test/SequenceTest.cpp b/libs/evoral/test/SequenceTest.cpp index a3dfabe139..16e93b37d2 100644 --- a/libs/evoral/test/SequenceTest.cpp +++ b/libs/evoral/test/SequenceTest.cpp @@ -25,7 +25,7 @@ SequenceTest::preserveEventOrderingTest () for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) { uint8_t buffer[3]; Event<Time>* event = new Event<Time>( - DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true + (Evoral::EventType)DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true ); event->buffer()[0] = MIDI_CMD_CONTROL; @@ -77,12 +77,12 @@ SequenceTest::iteratorSeekTest () bool on = true; for (Sequence<Time>::const_iterator i = seq->begin(Evoral::Beats(600)); i != seq->end(); ++i) { if (on) { - CPPUNIT_ASSERT((*i)->is_note_on()); + CPPUNIT_ASSERT(i->is_note_on()); CPPUNIT_ASSERT_EQUAL(i->time(), Time((num_notes + 6) * 100)); ++num_notes; on = false; } else { - CPPUNIT_ASSERT((*i)->is_note_off()); + CPPUNIT_ASSERT(i->is_note_off()); on = true; } } diff --git a/libs/evoral/test/SequenceTest.hpp b/libs/evoral/test/SequenceTest.hpp index de51f714a1..48dff308b6 100644 --- a/libs/evoral/test/SequenceTest.hpp +++ b/libs/evoral/test/SequenceTest.hpp @@ -31,13 +31,14 @@ public: }; } - uint32_t midi_event_type(uint8_t status) const { - status &= 0xf0; - switch (status) { - case MIDI_CMD_CONTROL: return CONTROL; - case MIDI_CMD_COMMON_SYSEX: return SYSEX; - default: return 0; - }; + virtual ParameterType midi_parameter_type(const uint8_t* buf, uint32_t len) const { + switch (buf[0] & 0xF0) { + case MIDI_CMD_CONTROL: return CONTROL; + case MIDI_CMD_COMMON_SYSEX: return SYSEX; + case MIDI_CMD_NOTE_ON: return NOTE; + case MIDI_CMD_NOTE_OFF: return NOTE; + default: return 0; + } } ParameterDescriptor descriptor(const Parameter& param) const { |