| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- /*
- ==============================================================================
- 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);
- }
- }
- }
|