summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSander Vocke <sandervocke@gmail.com>2024-07-28 09:24:01 +0200
committerSander Vocke <sandervocke@gmail.com>2024-07-28 09:24:01 +0200
commitfaaaf5d328429fd2c3f38131f7a874d056761f3f (patch)
treec49575d96ac820addefcf184ec7ad4f0151bc716 /test
parentf6660bc51fe8c02ff7c3b6188e8437c67712bddf (diff)
Openness development
Diffstat (limited to 'test')
-rw-r--r--test/dgreftest/midiinputengine.cc25
-rw-r--r--test/midimapparsertest.cc12
-rw-r--r--test/midimappertest.cc21
3 files changed, 35 insertions, 23 deletions
diff --git a/test/dgreftest/midiinputengine.cc b/test/dgreftest/midiinputengine.cc
index dbffec9..f0d4d25 100644
--- a/test/dgreftest/midiinputengine.cc
+++ b/test/dgreftest/midiinputengine.cc
@@ -143,6 +143,7 @@ void MidifileInputEngine::run(size_t pos, size_t len, std::vector<event_t>& even
current_event = smf_get_next_event(smf);
}
+ // FIXME: not sure if this section should support CC control?
while(current_event && current_event->time_seconds < current_max_time)
{
if(!smf_event_is_metadata(current_event))
@@ -155,16 +156,20 @@ void MidifileInputEngine::run(size_t pos, size_t len, std::vector<event_t>& even
int key = current_event->midi_buffer[1];
int velocity = current_event->midi_buffer[2];
- auto instruments = mmap.lookup(key);
- for(const auto& instrument_idx : instruments)
+ auto entries = mmap.lookup(key, MapFrom::Note, MapTo::PlayInstrument);
+ for(const auto& entry : entries)
{
- events.emplace_back();
- auto& event = events.back();
- event.type = EventType::OnSet;
- size_t evpos = current_event->time_seconds * (samplerate / speed);
- event.offset = evpos - pos;
- event.instrument = instrument_idx;
- event.velocity = velocity / 127.0;
+ auto instrument_idx = mmap.lookup_instrument(entry.instrument_name);
+ if (instrument_idx >= 0)
+ {
+ events.emplace_back();
+ auto& event = events.back();
+ event.type = EventType::OnSet;
+ size_t evpos = current_event->time_seconds * (samplerate / speed);
+ event.offset = evpos - pos;
+ event.instrument = instrument_idx;
+ event.velocity_or_state = velocity / 127.0;
+ }
}
}
}
@@ -182,7 +187,7 @@ void MidifileInputEngine::run(size_t pos, size_t len, std::vector<event_t>& even
else
{
assert(len >= 1);
- events.push_back({EventType::Stop, 0, len-1, 0.f});
+ events.push_back({EventType::Stop, 0, len-1, InstrumentStateKind::NoneOrAny, 0.f});
}
}
}
diff --git a/test/midimapparsertest.cc b/test/midimapparsertest.cc
index 3e77c44..7ec95fb 100644
--- a/test/midimapparsertest.cc
+++ b/test/midimapparsertest.cc
@@ -59,24 +59,24 @@ public:
const auto& midimap = parser.midimap;
uASSERT_EQUAL(6u, midimap.size());
- uASSERT_EQUAL(54, midimap[0].note_id);
+ uASSERT_EQUAL(54, midimap[0].from_id);
uASSERT_EQUAL(std::string("Crash_left_tip"), midimap[0].instrument_name);
- uASSERT_EQUAL(60, midimap[1].note_id);
+ uASSERT_EQUAL(60, midimap[1].from_id);
uASSERT_EQUAL(std::string("Crash_left_whisker"), midimap[1].instrument_name);
- uASSERT_EQUAL(55, midimap[2].note_id);
+ uASSERT_EQUAL(55, midimap[2].from_id);
uASSERT_EQUAL(std::string("Crash_right_tip"), midimap[2].instrument_name);
// These next two note numbers are intentionally the same and trigger two
// different instruments:
- uASSERT_EQUAL(62, midimap[3].note_id);
+ uASSERT_EQUAL(62, midimap[3].from_id);
uASSERT_EQUAL(std::string("Crash_right_whisker"), midimap[3].instrument_name);
- uASSERT_EQUAL(62, midimap[4].note_id);
+ uASSERT_EQUAL(62, midimap[4].from_id);
uASSERT_EQUAL(std::string("Hihat_closed"), midimap[4].instrument_name);
- uASSERT_EQUAL(56, midimap[5].note_id);
+ uASSERT_EQUAL(56, midimap[5].from_id);
uASSERT_EQUAL(std::string("Hihat_closed"), midimap[5].instrument_name);
}
diff --git a/test/midimappertest.cc b/test/midimappertest.cc
index 703c646..e8f02db 100644
--- a/test/midimappertest.cc
+++ b/test/midimappertest.cc
@@ -66,25 +66,29 @@ public:
mapper.swap(instrmap, midimap);
{
- auto is = mapper.lookup(54);
+ auto is = mapper.lookup_instruments(
+ mapper.lookup(54, MapFrom::Note, MapTo::PlayInstrument));
uASSERT_EQUAL(1u, is.size());
uASSERT_EQUAL(0, is[0]);
}
{
- auto is = mapper.lookup(60);
+ auto is = mapper.lookup_instruments(
+ mapper.lookup(60, MapFrom::Note, MapTo::PlayInstrument));
uASSERT_EQUAL(1u, is.size());
uASSERT_EQUAL(1, is[0]);
}
{
- auto is = mapper.lookup(55);
+ auto is = mapper.lookup_instruments(
+ mapper.lookup(55, MapFrom::Note, MapTo::PlayInstrument));
uASSERT_EQUAL(1u, is.size());
uASSERT_EQUAL(2, is[0]);
}
{
- auto is = mapper.lookup(62);
+ auto is = mapper.lookup_instruments(
+ mapper.lookup(62, MapFrom::Note, MapTo::PlayInstrument));
uASSERT_EQUAL(2u, is.size());
// We don't care about the order, so just count the instances
uASSERT_EQUAL(1u, std::count(is.begin(), is.end(), 3));
@@ -92,7 +96,8 @@ public:
}
{
- auto is = mapper.lookup(56);
+ auto is = mapper.lookup_instruments(
+ mapper.lookup(56, MapFrom::Note, MapTo::PlayInstrument));
uASSERT_EQUAL(1u, is.size());
uASSERT_EQUAL(4, is[0]);
}
@@ -124,13 +129,15 @@ public:
// no such note id
{
- auto is = mapper.lookup(42);
+ auto is = mapper.lookup_instruments(
+ mapper.lookup(42, MapFrom::Note, MapTo::PlayInstrument));
uASSERT_EQUAL(0u, is.size());
}
// no such instrument
{
- auto is = mapper.lookup(60);
+ auto is = mapper.lookup_instruments(
+ mapper.lookup(60, MapFrom::Note, MapTo::PlayInstrument));
uASSERT_EQUAL(0u, is.size());
}
}