diff --git a/dep/oui-blendish b/dep/oui-blendish index b7066201..383f24f6 160000 --- a/dep/oui-blendish +++ b/dep/oui-blendish @@ -1 +1 @@ -Subproject commit b7066201022a757cbcbd986d8c91d565e4daef90 +Subproject commit 383f24f6ed41facf25eda0d32b0f6bc9aee96e53 diff --git a/include/bridge.hpp b/include/bridge.hpp index 28dfbc06..6452a7cd 100644 --- a/include/bridge.hpp +++ b/include/bridge.hpp @@ -9,8 +9,8 @@ namespace rack { void bridgeInit(); void bridgeDestroy(); -void bridgeMidiSubscribe(int channel, MidiInput *midi); -void bridgeMidiUnsubscribe(int channel, MidiInput *midi); +void bridgeMidiSubscribe(int channel, MidiIO *midi); +void bridgeMidiUnsubscribe(int channel, MidiIO *midi); void bridgeAudioSubscribe(int channel, AudioIO *audio); void bridgeAudioUnsubscribe(int channel, AudioIO *audio); diff --git a/include/midi.hpp b/include/midi.hpp index ff1f9220..88d2d097 100644 --- a/include/midi.hpp +++ b/include/midi.hpp @@ -58,10 +58,9 @@ struct MidiIO { void setDevice(int device); std::string getChannelName(int channel); - /** Returns whether the audio stream is open and running */ - bool isActive(); json_t *toJson(); void fromJson(json_t *rootJ); + virtual void onMessage(MidiMessage message) {} }; @@ -70,7 +69,6 @@ struct MidiInput : MidiIO { MidiInput(); ~MidiInput(); void setDriver(int driver) override; - virtual void onMessage(MidiMessage message) {} }; diff --git a/src/bridge.cpp b/src/bridge.cpp index c91e3958..d59e72a8 100644 --- a/src/bridge.cpp +++ b/src/bridge.cpp @@ -23,7 +23,7 @@ namespace rack { struct BridgeClientConnection; static BridgeClientConnection *connections[BRIDGE_NUM_PORTS] = {}; static AudioIO *audioListeners[BRIDGE_NUM_PORTS] = {}; -static MidiInput *midiListeners[BRIDGE_NUM_PORTS] = {}; +static MidiIO *midiListeners[BRIDGE_NUM_PORTS] = {}; static std::thread serverThread; static bool serverRunning = false; @@ -377,7 +377,7 @@ void bridgeDestroy() { serverThread.join(); } -void bridgeMidiSubscribe(int port, MidiInput *midi) { +void bridgeMidiSubscribe(int port, MidiIO *midi) { if (!(0 <= port && port < BRIDGE_NUM_PORTS)) return; // Check if a Midi is already subscribed on the port @@ -388,7 +388,7 @@ void bridgeMidiSubscribe(int port, MidiInput *midi) { connections[port]->refreshAudio(); } -void bridgeMidiUnsubscribe(int port, MidiInput *midi) { +void bridgeMidiUnsubscribe(int port, MidiIO *midi) { if (!(0 <= port && port < BRIDGE_NUM_PORTS)) return; if (midiListeners[port] != midi) diff --git a/src/midi.cpp b/src/midi.cpp index f5c09215..9a7f314f 100644 --- a/src/midi.cpp +++ b/src/midi.cpp @@ -39,18 +39,25 @@ int MidiIO::getDeviceCount() { if (rtMidi) { return rtMidi->getPortCount(); } + else if (driver == BRIDGE_DRIVER) { + return BRIDGE_NUM_PORTS; + } return 0; } std::string MidiIO::getDeviceName(int device) { + if (device < 0) + return ""; + if (rtMidi) { - if (device < 0) - return ""; if (device == this->device) return deviceName; else return rtMidi->getPortName(device); } + else if (driver == BRIDGE_DRIVER) { + return stringf("Port %d", device + 1); + } return ""; } @@ -64,6 +71,15 @@ void MidiIO::setDevice(int device) { } this->device = device; } + else if (driver == BRIDGE_DRIVER) { + if (device >= 0) { + bridgeMidiSubscribe(device, this); + } + else { + bridgeMidiUnsubscribe(device, this); + } + this->device = device; + } } std::string MidiIO::getChannelName(int channel) { @@ -73,12 +89,6 @@ std::string MidiIO::getChannelName(int channel) { return stringf("Channel %d", channel + 1); } -bool MidiIO::isActive() { - if (rtMidi) - return rtMidi->isPortOpen(); - return false; -} - json_t *MidiIO::toJson() { json_t *rootJ = json_object(); json_object_set_new(rootJ, "driver", json_integer(driver)); @@ -156,7 +166,7 @@ void MidiInput::setDriver(int driver) { this->driver = rtMidiIn->getCurrentApi(); } else if (driver == BRIDGE_DRIVER) { - + this->driver = BRIDGE_DRIVER; } }