From 95aac485c7c5962f86aecfb66c15369125233f28 Mon Sep 17 00:00:00 2001 From: Roland Rabien Date: Thu, 31 Aug 2023 19:19:28 -0700 Subject: [PATCH] Pink noise --- modules/gin | 2 +- plugin/Resources/layout.json | 5 +++-- plugin/Source/Panels.h | 1 + plugin/Source/PluginProcessor.cpp | 13 +++++++++++++ plugin/Source/PluginProcessor.h | 2 +- plugin/Source/WavetableVoice.cpp | 2 +- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/gin b/modules/gin index aba3276..1685be0 160000 --- a/modules/gin +++ b/modules/gin @@ -1 +1 @@ -Subproject commit aba327620034062fe0521ac75858a3b0429023cc +Subproject commit 1685be0cececd415a8c8d485efe18f9121b16ced diff --git a/plugin/Resources/layout.json b/plugin/Resources/layout.json index f8aa77e..ea5caab 100644 --- a/plugin/Resources/layout.json +++ b/plugin/Resources/layout.json @@ -4,13 +4,14 @@ { "id": "osc[1..2]", "x": "0,prevR()+1", "y": 0, "w": "parW()/2", "h": 163 }, { "id": "noise", "x": "0", "y": "prevB()+1", "w": 120, "h": 163, "children": [ - { "id": "Level", "x": 0, "y": "23 + 35", "w": 56, "h": 70 }, + { "id": "Type", "x": "56/2", "y": 23, "w": 56, "h": 70 }, + { "id": "Level", "x": 0, "y": "prevB()", "w": 56, "h": 70 }, { "id": "Pan", "x": "prevR()", "y": "prevY()", "w": 56, "h": 70 } ] }, { "id": "sub", "x": "prevR()+1", "y": "prevY()", "w": 112, "h": 163, "children": [ - { "id": "Wave", "x": 0, "y": 23, "w": 56, "h": 70 }, + { "id": "Wave", "x": "56", "y": 23, "w": 56, "h": 70 }, { "id": "Tune", "x": "prevR()", "y": 23, "w": 56, "h": 70 }, { "id": "Level", "x": 0, "y": "prevB()", "w": 56, "h": 70 }, { "id": "Pan", "x": "prevR()", "y": "prevY()", "w": 56, "h": 70 } diff --git a/plugin/Source/Panels.h b/plugin/Source/Panels.h index c8315e6..f89c9a5 100644 --- a/plugin/Source/Panels.h +++ b/plugin/Source/Panels.h @@ -182,6 +182,7 @@ public: addEnable (noise.enable); + addControl (new gin::Select (noise.type), 0, 0); addControl (new gin::Knob (noise.level, true), 0, 0); addControl (new gin::Knob (noise.pan, true), 0, 1); } diff --git a/plugin/Source/PluginProcessor.cpp b/plugin/Source/PluginProcessor.cpp index 492f9ab..aafb31c 100644 --- a/plugin/Source/PluginProcessor.cpp +++ b/plugin/Source/PluginProcessor.cpp @@ -16,6 +16,18 @@ static juce::String subTextFunction (const gin::Parameter&, float v) } } +static juce::String noiseTextFunction (const gin::Parameter&, float v) +{ + switch (int (v)) + { + case 0: return "White"; + case 1: return "Pink"; + default: + jassertfalse; + return {}; + } +} + static juce::String lfoTextFunction (const gin::Parameter&, float v) { switch ((gin::LFO::WaveShape)int (v)) @@ -138,6 +150,7 @@ void WavetableAudioProcessor::NoiseParams::setup (WavetableAudioProcessor& p) juce::String nm = "Noise "; enable = p.addIntParam (id + "enable", nm + "Enable", "Enable", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0f, 0.0f); + type = p.addIntParam (id + "type", nm + "Type", "Type", "", { 0.0, 1.0, 1.0, 1.0 }, 0.0, 0.0f, noiseTextFunction); level = p.addExtParam (id + "level", nm + "Level", "Level", "db", { -100.0, 0.0, 1.0, 4.0 }, 0.0, 0.0f); pan = p.addExtParam (id + "pan", nm + "Pan", "Pan", "", { -1.0, 1.0, 0.0, 1.0 }, 0.0, 0.0f); diff --git a/plugin/Source/PluginProcessor.h b/plugin/Source/PluginProcessor.h index 12f97d2..fae021f 100644 --- a/plugin/Source/PluginProcessor.h +++ b/plugin/Source/PluginProcessor.h @@ -70,7 +70,7 @@ public: { NoiseParams() = default; - gin::Parameter::Ptr enable, level, pan; + gin::Parameter::Ptr enable, type, level, pan; void setup (WavetableAudioProcessor& p); diff --git a/plugin/Source/WavetableVoice.cpp b/plugin/Source/WavetableVoice.cpp index 1cfa9f3..4aeff20 100644 --- a/plugin/Source/WavetableVoice.cpp +++ b/plugin/Source/WavetableVoice.cpp @@ -243,7 +243,7 @@ void WavetableVoice::updateParams (int blockSize) if (proc.noiseParams.enable->isOn()) { - noiseParams.wave = gin::Wave::noise; + noiseParams.wave = gin::Wave::whiteNoise; noiseParams.leftGain = getValue (proc.noiseParams.level) * (1.0f - getValue (proc.noiseParams.pan)); noiseParams.rightGain = getValue (proc.noiseParams.level) * (1.0f + getValue (proc.noiseParams.pan));