diff --git a/modules/juce_audio_basics/midi/ump/juce_UMPDispatcher.h b/modules/juce_audio_basics/midi/ump/juce_UMPDispatcher.h index 1bbaa6701f..3ba42a9d4f 100644 --- a/modules/juce_audio_basics/midi/ump/juce_UMPDispatcher.h +++ b/modules/juce_audio_basics/midi/ump/juce_UMPDispatcher.h @@ -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{}; }; //============================================================================== diff --git a/modules/juce_audio_devices/midi_io/ump/juce_UMPBytestreamInputHandler.h b/modules/juce_audio_devices/midi_io/ump/juce_UMPBytestreamInputHandler.h index 86273c20f8..97fa76f823 100644 --- a/modules/juce_audio_devices/midi_io/ump/juce_UMPBytestreamInputHandler.h +++ b/modules/juce_audio_devices/midi_io/ump/juce_UMPBytestreamInputHandler.h @@ -107,7 +107,7 @@ struct BytestreamToBytestreamHandler : public BytestreamInputHandler struct BytestreamToUMPHandler : public BytestreamInputHandler { BytestreamToUMPHandler (PacketProtocol protocol, Receiver& c) - : recipient (c), dispatcher (protocol, 2048) {} + : recipient (c), dispatcher (0, protocol, 2048) {} /** Provides an `operator()` which can create an input handler for a given @@ -137,9 +137,9 @@ struct BytestreamToUMPHandler : public BytestreamInputHandler void pushMidiData (const void* data, int bytes, double time) override { const auto* ptr = static_cast (data); - dispatcher.dispatch (Span { ptr, (size_t) bytes }, time, [&] (const View& v) + dispatcher.dispatch (Span { ptr, (size_t) bytes }, time, [&] (const View& v, double t) { - recipient.packetReceived (v, time); + recipient.packetReceived (v, t); }); }