Prechádzať zdrojové kódy

JUCE part updated with OSC messages reception

LuigiBiasi-Athenagroup 6 mesiacov pred
rodič
commit
97356656f3

+ 1 - 1
JUCE/CMLSProject/Source/CMLSProcessorChain.cpp

@@ -55,7 +55,7 @@ void CMLSProcessorChain::muteProcessrInSlot(int slot)
 	slots[slot] = false;
 }
 
-void CMLSProcessorChain::unmuteProcessrInSlot(int slot)
+void CMLSProcessorChain::unmuteProcessorInSlot(int slot)
 {
 	slots[slot] = true;
 }

+ 1 - 1
JUCE/CMLSProject/Source/CMLSProcessorChain.h

@@ -23,7 +23,7 @@ class CMLSProcessorChain
 		
 		int pushProcessor(juce::dsp::ProcessorBase& processor);
 		void muteProcessrInSlot(int slot);
-		void unmuteProcessrInSlot(int slot);
+		void unmuteProcessorInSlot(int slot);
 		void swapPlaces(int slot1, int slot2);
 	
 	private:

+ 102 - 8
JUCE/CMLSProject/Source/OSCReceiverWrapper.cpp

@@ -11,8 +11,11 @@
 #include "OSCReceiverWrapper.h"
 
 OSCReceiverWrapper::OSCReceiverWrapper(int port, juce::AudioProcessor* pluginProcessor) {
-    this->connect(port);
-	this->pluginProcessor = pluginProcessor;
+	this->pluginProcessor = (CMLSProjectAudioProcessor*)pluginProcessor;
+
+    if (!this->connect(port)) {
+        this->oscConnectionError();
+    }
 }
 
 OSCReceiverWrapper::~OSCReceiverWrapper() {}
@@ -21,14 +24,105 @@ void OSCReceiverWrapper::oscMessageReceived(const juce::OSCMessage& message)
 {
     if (!message.isEmpty() && message.size() == 1) {
 	    auto address = message.getAddressPattern().toString();
-        auto argument = message[0].getString();
+        auto argument = message[0].getFloat32();
 
-        // Interpret each message
-		if (address == "/") {
-            //this->pluginProcessor->getCallbackLock...
+        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(const juce::String& errorMessage)
-{}
+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);
+        }
+    }
+}

+ 27 - 4
JUCE/CMLSProject/Source/OSCReceiverWrapper.h

@@ -10,16 +10,39 @@
 
 #pragma once
 #include <JuceHeader.h>
+#include "PluginProcessor.h"
 
-class OSCReceiverWrapper : public juce::OSCReceiver,
-    private juce::OSCReceiver::ListenerWithOSCAddress<juce::String>
+enum Preset {
+    NONE,
+    PENCIL,
+    CRAYON,
+    FOUNTAINPEN,
+    PEN,
+    MARKER,
+    MONOLINE,
+    WATERCOLOR
+};
+
+class OSCReceiverWrapper : public juce::Component,
+                           private juce::OSCReceiver,
+                           private juce::OSCReceiver::ListenerWithOSCAddress<juce::String>
 {
     public:
         OSCReceiverWrapper(int port, juce::AudioProcessor* pluginProcessor);
         ~OSCReceiverWrapper();
 
 		void oscMessageReceived(const juce::OSCMessage& message) override;
-		void oscConnectionError(const juce::String& errorMessage);
+		void oscConnectionError();
+
+        void processMessage();
     private:
-		juce::AudioProcessor* pluginProcessor;
+        enum Preset currentPreset = NONE;
+        float x;
+        float y;
+        float aspectX;
+        float aspectY;
+        float pressure;
+        float thickness;
+
+        CMLSProjectAudioProcessor* pluginProcessor;
 };

+ 1 - 1
JUCE/CMLSProject/Source/PluginProcessor.cpp

@@ -194,7 +194,7 @@ void CMLSProjectAudioProcessor::muteEffectInSlot(int slot) {
 }
 
 void CMLSProjectAudioProcessor::unmuteEffectInSlot(int slot) {
-    this->processorChain.unmuteProcessrInSlot(slot);
+    this->processorChain.unmuteProcessorInSlot(slot);
 }
 
 void CMLSProjectAudioProcessor::swapEffectInSlot(int slot1, int slot2) {