From e89620df275df927667118a60cf4e01eafbc8b4b Mon Sep 17 00:00:00 2001 From: michalcourson Date: Wed, 5 Nov 2025 19:17:34 -0500 Subject: [PATCH] closes #3 Added freeze pitch and volume controls --- Assets/web/src/App.js | 2 ++ Source/PluginProcessor.cpp | 2 ++ Source/PluginProcessor.h | 14 ++++++++++++++ Source/Shifter.cpp | 8 +++++++- Source/Shifter.h | 2 ++ Source/shifter_voice.cpp | 6 +++++- Source/shifter_voice.h | 2 ++ 7 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Assets/web/src/App.js b/Assets/web/src/App.js index 33b9b8e..8ca9f1e 100644 --- a/Assets/web/src/App.js +++ b/Assets/web/src/App.js @@ -57,6 +57,8 @@ function App() { + + diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index b58a534..3e9e691 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -69,6 +69,8 @@ void WebViewPluginAudioProcessor::processBlock(juce::AudioBuffer& buffer, shifter.SetHarmonyMix(state.getParameterAsValue("harmonyMix").getValue()); shifter.SetAutoTuneEnable(state.getParameterAsValue("autoTuneEnabled").getValue()); shifter.SetFreeze(state.getParameterAsValue("freezeEnabled").getValue()); + shifter.SetFreezePitchAdjust(state.getParameterAsValue("freezePitch").getValue()); + shifter.SetFreezeVolume(state.getParameterAsValue("freezeVolume").getValue()); juce::AudioBuffer const_buff; const_buff.makeCopyOf(buffer); diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 0bf3bb7..a2570f0 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -86,6 +86,20 @@ public: "Portamento Speed", NormalisableRange {0.001f, 0.2f, .001f}, .01f); + + sliderIds.push_back("freezePitch"); + addToLayout(layout, + ParameterID("freezePitch"), + "Freeze pitch", + NormalisableRange {-12.0f, 12.0f, 1.00f}, + 0.0f); + + sliderIds.push_back("freezeVolume"); + addToLayout(layout, + ParameterID("freezeVolume"), + "Freeze Volume", + NormalisableRange {0.0f, 1.0f, .01f}, + 0.5f); toggleIds.push_back("autoTuneEnabled"); diff --git a/Source/Shifter.cpp b/Source/Shifter.cpp index 3faf871..c85af84 100644 --- a/Source/Shifter.cpp +++ b/Source/Shifter.cpp @@ -215,7 +215,7 @@ void Shifter::GetSamples(float** output, const float* input, size_t size) if (voices[i].IsActive()) { freeze_voices[i].Trigger(voices[i].GetMidiNote()); freeze_voices[i].panning = voices[i].panning; - freeze_voices[i].SetPortamentoTime(0.0001f); + freeze_voices[i].SetPortamentoTime(0.05f); } } } @@ -402,4 +402,10 @@ void Shifter::SetFreeze(bool freeze) { } } freeze_mode = freeze; +} + +void Shifter::SetFreezePitchAdjust(float val) { + for(int i = 0; i < MAX_VOICES; ++i) { + freeze_voices[i].SetPitchAdjust(val); + } } \ No newline at end of file diff --git a/Source/Shifter.h b/Source/Shifter.h index e3e65ea..d8597f7 100644 --- a/Source/Shifter.h +++ b/Source/Shifter.h @@ -159,6 +159,8 @@ public: void SetHarmonyMix(float mix); void SetAutoTuneEnable(bool enable) { enable_autotune = enable; } void SetFreeze(bool); + void SetFreezePitchAdjust(float val); + void SetFreezeVolume(float val) { freeze_volume = val; } float out_midi = 40; ShifterVoice voices[MAX_VOICES]; diff --git a/Source/shifter_voice.cpp b/Source/shifter_voice.cpp index dd50a3a..4f3e4f8 100644 --- a/Source/shifter_voice.cpp +++ b/Source/shifter_voice.cpp @@ -54,7 +54,7 @@ void ShifterVoice::Release() { void ShifterVoice::Process() { current_amplitude = amplitude_envelope_.Process(onoff_); - current_period_ = sample_rate_ / mtof(portamento_.Process((float)current_midi)); + current_period_ = sample_rate_ / mtof(portamento_.Process((float)current_midi + pitch_adjust)); period_counter++; overflow_ = period_counter >= current_period_; if (overflow_) { @@ -93,4 +93,8 @@ float ShifterVoice::GetPanning(int channel) const { case 1: return panning > .5 ? 1.0 : panning * 2.0f; } +} + +void ShifterVoice::SetPitchAdjust(float adj) { + pitch_adjust = adj; } \ No newline at end of file diff --git a/Source/shifter_voice.h b/Source/shifter_voice.h index 6e07baf..438ad7c 100644 --- a/Source/shifter_voice.h +++ b/Source/shifter_voice.h @@ -32,6 +32,7 @@ public: void SetAdsrTimes(float attack, float decay, float release); float GetPanning(int channel) const; int GetMidiNote() const { return current_midi; } + void SetPitchAdjust(float); bool onoff_; float panning; @@ -46,5 +47,6 @@ private: float current_period_; float current_amplitude; float period_counter; + float pitch_adjust = 0.0f; }; \ No newline at end of file