From 1c53d7b35f8fbb1125249f8db11a00217e81314b Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 17 Mar 2018 15:46:47 -0400 Subject: [PATCH] Updated blendish, bridge protocol --- dep/oui-blendish | 2 +- include/bridge.hpp | 4 +-- include/bridgeprotocol.hpp | 62 ++++++++++++++++++++++++++++++++++++++ src/audio.cpp | 2 +- src/bridge.cpp | 19 +----------- src/plugin.cpp | 2 +- src/window.cpp | 6 ++-- 7 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 include/bridgeprotocol.hpp 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 62980056..2605bbfc 100644 --- a/include/bridge.hpp +++ b/include/bridge.hpp @@ -1,13 +1,11 @@ #pragma once +#include "bridgeprotocol.hpp" #include "audio.hpp" namespace rack { -static const int BRIDGE_NUM_PORTS = 16; - - void bridgeInit(); void bridgeDestroy(); void bridgeAudioSubscribe(int channel, AudioIO *audio); diff --git a/include/bridgeprotocol.hpp b/include/bridgeprotocol.hpp new file mode 100644 index 00000000..160b90ae --- /dev/null +++ b/include/bridgeprotocol.hpp @@ -0,0 +1,62 @@ +#pragma once + + +namespace rack { + + +static const int BRIDGE_NUM_PORTS = 16; +// A random number which prevents connection from other protocols and old Bridge versions +const int BRIDGE_HELLO = 0xff00fefd; + + +/** All commands are called from the client and served by the server +send +- uint8_t cmd +*/ +enum BridgeCommand { + NO_COMMAND = 0, + /** Initial state of the state machine. The client should not send the command number itself, just its arguments. + send + - uint32_t hello + */ + START_COMMAND, + /** Requests the server to shut down the client */ + QUIT_COMMAND, + /** Sets the port + send + - uint8_t port + */ + PORT_SET_COMMAND, + /** Sends a 3-byte MIDI command + send + - uint8_t msg[3] + */ + MIDI_MESSAGE_SEND_COMMAND, + /** Sets the audio sample rate + send + - uint32_t sampleRate + */ + AUDIO_SAMPLE_RATE_SET_COMMAND, + /** Sets the number of audio channels + Currently not supported, hard-coded at 2. + send + - uint8_t channels + */ + AUDIO_CHANNELS_SET_COMMAND, + /** Sends and receives an audio buffer + send + - uint32_t length + - float input[n] + recv + - float output[n] + */ + AUDIO_PROCESS_COMMAND, + /** Resumes the audio buffer, forcing Rack to wait on an audio buffer */ + AUDIO_ACTIVATE, + /** Pauses the audio buffer, allowing Rack to not wait on an audio buffer */ + AUDIO_DEACTIVATE, + NUM_COMMANDS +}; + + +} // namespace rack diff --git a/src/audio.cpp b/src/audio.cpp index f5365b42..254a580b 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -206,7 +206,7 @@ void AudioIO::openStream() { setChannels(clamp((int) deviceInfo.outputChannels - offset, 0, maxChannels), clamp((int) deviceInfo.inputChannels - offset, 0, maxChannels)); if (numOutputs == 0 && numInputs == 0) { - warn("RtAudio device %d has 0 inputs and 0 outputs"); + warn("RtAudio device %d has 0 inputs and 0 outputs", device); return; } diff --git a/src/bridge.cpp b/src/bridge.cpp index 47409dfa..f51fa0e9 100644 --- a/src/bridge.cpp +++ b/src/bridge.cpp @@ -21,21 +21,6 @@ namespace rack { -enum BridgeCommand { - NO_COMMAND = 0, - START_COMMAND, - QUIT_COMMAND, - PORT_SET_COMMAND, - MIDI_MESSAGE_SEND_COMMAND, - AUDIO_SAMPLE_RATE_SET_COMMAND, - AUDIO_CHANNELS_SET_COMMAND, - AUDIO_BUFFER_SEND_COMMAND, - AUDIO_ACTIVATE, - AUDIO_DEACTIVATE, - NUM_COMMANDS -}; - - static const int RECV_BUFFER_SIZE = (1<<13); static const int RECV_QUEUE_SIZE = (1<<17); @@ -192,7 +177,7 @@ struct BridgeClientConnection { } } break; - case AUDIO_BUFFER_SEND_COMMAND: { + case AUDIO_PROCESS_COMMAND: { if (audioBufferLength < 0) { // Get audio buffer size if (recvQueue.size() >= 4) { @@ -216,8 +201,6 @@ struct BridgeClientConnection { float output[audioBufferLength]; processStream(input, output, frames); // Send output buffer - send(AUDIO_BUFFER_SEND_COMMAND); - send(audioBufferLength); send((uint8_t*) output, audioBufferLength * sizeof(float)); audioBufferLength = -1; diff --git a/src/plugin.cpp b/src/plugin.cpp index d0b2e132..0f7725ce 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -268,7 +268,7 @@ static bool syncPlugin(json_t *pluginJ, bool dryRun) { std::string zipPath = pluginPath + ".zip"; bool success = requestDownload(download, zipPath, &downloadProgress); if (!success) { - warn("Plugin %s download was unsuccessful"); + warn("Plugin %s download was unsuccessful", slug.c_str()); return false; } diff --git a/src/window.cpp b/src/window.cpp index 49a45eb4..6cebbff1 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -547,9 +547,9 @@ void windowSetTheme(NVGcolor bg, NVGcolor fg) { // Assume dark background and light foreground BNDwidgetTheme w; - w.outlineColor = bg; + w.outlineColor = colorMinus(bg, nvgRGB(0x10, 0x10, 0x10)); w.itemColor = fg; - w.innerColor = bg; + w.innerColor = colorMinus(bg, nvgRGB(0x10, 0x10, 0x10)); w.innerSelectedColor = colorPlus(bg, nvgRGB(0x30, 0x30, 0x30)); w.textColor = fg; w.textSelectedColor = fg; @@ -571,7 +571,7 @@ void windowSetTheme(NVGcolor bg, NVGcolor fg) { t.menuTheme = w; t.menuItemTheme = w; - t.sliderTheme.itemColor = bg; + t.sliderTheme.itemColor = colorMinus(bg, nvgRGB(0x10, 0x10, 0x10)); t.sliderTheme.innerColor = colorPlus(bg, nvgRGB(0x50, 0x50, 0x50)); t.sliderTheme.innerSelectedColor = colorPlus(bg, nvgRGB(0x60, 0x60, 0x60));