summaryrefslogtreecommitdiff
path: root/src/audioinputenginemidi.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-08-08 10:34:54 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-08-08 10:34:54 +0200
commitf43935b5c873676a632b23cbfcef45a4431b233d (patch)
treead1473fa34f3da5292e3344a99ed447261d99584 /src/audioinputenginemidi.cc
parenta2483a839264369482fff135d33f007ded266d3c (diff)
Add support for a single midi note that plays multiple instruments.
Diffstat (limited to 'src/audioinputenginemidi.cc')
-rw-r--r--src/audioinputenginemidi.cc51
1 files changed, 27 insertions, 24 deletions
diff --git a/src/audioinputenginemidi.cc b/src/audioinputenginemidi.cc
index 8732d8d..69aeeb6 100644
--- a/src/audioinputenginemidi.cc
+++ b/src/audioinputenginemidi.cc
@@ -117,32 +117,35 @@ void AudioInputEngineMidi::processNote(const std::uint8_t* midi_buffer,
auto key = midi_buffer[1];
auto velocity = midi_buffer[2];
auto instrument_idx = mmap.lookup(key);
-
- switch(midi_buffer[0] & NoteMask)
+ auto instruments = mmap.lookup(key);
+ for(const auto& instrument_idx : instruments)
{
- case NoteOff:
- // Ignore for now
- break;
-
- case NoteOn:
- if(velocity != 0 && instrument_idx != -1)
- {
- // maps velocities to [.5/127, 126.5/127]
- auto centered_velocity = (velocity-.5f)/127.0f;
- events.push_back({EventType::OnSet, (std::size_t)instrument_idx,
- offset, centered_velocity});
- }
- break;
-
- case NoteAftertouch:
- if(velocity > 0 && instrument_idx != -1)
+ switch(midi_buffer[0] & NoteMask)
{
- events.push_back({EventType::Choke, (std::size_t)instrument_idx,
- offset, .0f});
+ case NoteOff:
+ // Ignore for now
+ break;
+
+ case NoteOn:
+ if(velocity != 0)
+ {
+ // maps velocities to [.5/127, 126.5/127]
+ auto centered_velocity = (velocity-.5f)/127.0f;
+ events.push_back({EventType::OnSet, (std::size_t)instrument_idx,
+ offset, centered_velocity});
+ }
+ break;
+
+ case NoteAftertouch:
+ if(velocity > 0)
+ {
+ events.push_back({EventType::Choke, (std::size_t)instrument_idx,
+ offset, .0f});
+ }
+ break;
+
+ default:
+ break;
}
- break;
-
- default:
- break;
}
}