1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

MIDI: Update UMPDispatcher to allow dispatching on a specific group

This commit is contained in:
reuk 2025-03-06 17:40:43 +00:00
parent fa1f8ed54e
commit 7dc906fa1b
No known key found for this signature in database
2 changed files with 18 additions and 8 deletions

View file

@ -92,9 +92,10 @@ public:
Channel messages will be converted to the requested protocol format `pp`.
`storageSize` bytes will be allocated to store incomplete messages.
*/
explicit BytestreamToUMPDispatcher (PacketProtocol pp, int storageSize)
BytestreamToUMPDispatcher (uint8_t targetGroup, PacketProtocol pp, int storageSize)
: concatenator (storageSize),
converter (pp)
converter (pp),
group (targetGroup)
{}
void reset()
@ -123,13 +124,16 @@ public:
void handleIncomingMidiMessage (void*, const MidiMessage& msg) const
{
Conversion::toMidi1 ({ 0, msg.asSpan() }, [&] (const View& view)
Conversion::toMidi1 ({ dispatch.group, msg.asSpan() }, [&] (const View& view)
{
dispatch.converter.convert (view, *callbackPtr);
dispatch.converter.convert (view, [&] (const View& v)
{
(*callbackPtr) (v, msg.getTimeStamp());
});
});
}
void handlePartialSysexMessage (void*, const uint8_t*, int, double) const {}
void handlePartialSysexMessage (void*, const uint8*, int, double) const {}
BytestreamToUMPDispatcher& dispatch;
CallbackPtr callbackPtr = nullptr;
@ -139,9 +143,15 @@ public:
concatenator.pushMidiData (bytes, timestamp, (void*) nullptr, inputCallback);
}
PacketProtocol getProtocol() const
{
return converter.getProtocol();
}
private:
MidiDataConcatenator concatenator;
GenericUMPConverter converter;
uint8_t group{};
};
//==============================================================================