/* ============================================================================== OSCReceiverWrapper.cpp Created: 5 May 2025 2:34:15pm Author: Luigi ============================================================================== */ #include "OSCReceiverWrapper.h" OSCReceiverWrapper::OSCReceiverWrapper(int port, juce::AudioProcessor* pluginProcessor) { this->pluginProcessor = (CMLSProjectAudioProcessor*)pluginProcessor; if (!this->connect(port)) { this->oscConnectionError(); } } OSCReceiverWrapper::~OSCReceiverWrapper() {} void OSCReceiverWrapper::oscMessageReceived(const juce::OSCMessage& message) { if (!message.isEmpty() && message.size() == 1) { auto address = message.getAddressPattern().toString(); auto argument = message[0].getFloat32(); if (address == "/r") { // Unused } else if (address == "/g") { // Unused } else if (address == "/b") { // Unused } else if (address == "a") { // Unused } // Pen types are used to manage the presets else if (address == "/pen") { // Unused } else if (address == "/pencil") { this->currentPreset = Preset::PENCIL; } else if (address == "/marker") { // Unused } else if (address == "/monoline") { // Unused } else if (address == "/crayon") { this->currentPreset = Preset::CRAYON; } else if (address == "/fountainPen") { // Preset #3 } else if (address == "/waterColor") { this->currentPreset = Preset::WATERCOLOR; } else if (address == "/bitmapEraser") { } else if (address == "/vectorEraser") { } else if (address == "/canvasWidth") { } else if (address == "/canvasHeight") { } else if (address == "/drawingWidth") { this->thickness = argument; } else if (address == "/eraserWidth") { } // Value assignment else if (address == "/x") { } else if (address == "/y") { } else if (address == "/pressure") { } else if (address == "/aspectX") { this->aspectX = argument; this->processMessage(); } else if (address == "/aspectY") { this->aspectY = argument; this->processMessage(); } } } void OSCReceiverWrapper::oscConnectionError() {} void OSCReceiverWrapper::processMessage() { if (this->currentPreset == Preset::PENCIL) { this->pluginProcessor->setReverbRoomSize(this->aspectY + 0.5); } else if (this->currentPreset == Preset::CRAYON) { this->pluginProcessor->setDelayAmount(this->aspectX + 0.5); this->pluginProcessor->setReverbDryWet(this->aspectY + 0.5); } else if (this->currentPreset == Preset::WATERCOLOR) { // Changing parameters of single effects if (this->thickness <= 6) { //EQ this->pluginProcessor->setEqLowGain(this->aspectX + 0.5); this->pluginProcessor->setEqHighGain(this->aspectY + 0.5); } else if (this->thickness <= 12) { // Dist this->pluginProcessor->setDistortionDrive(this->aspectY + 0.5); this->pluginProcessor->setDistortionMix(this->aspectX + 0.5); } else if (this->thickness <= 18) { // Chorus this->pluginProcessor->setChorusAmount(this->aspectY + 0.5); this->pluginProcessor->setChorusDryWet(this->aspectX + 0.5); } else if (this->thickness <= 24) { // Reverb this->pluginProcessor->setReverbRoomSize(this->aspectY + 0.5); this->pluginProcessor->setReverbDryWet(this->aspectX + 0.5); } else if (this->thickness <= 30) { //Delay this->pluginProcessor->setDelayAmount(this->aspectY + 0.5); this->pluginProcessor->setDelayDryWet(this->aspectX + 0.5); } } }