From e62923d072cd105b7eef7be89db4197d3cc9f8b8 Mon Sep 17 00:00:00 2001 From: Matthijs Hollemans Date: Thu, 11 Apr 2024 21:54:00 +0200 Subject: [PATCH] add parameters for everything --- Source/AudioProcessing/AudioGraph.h | 6 +++- Source/Parameters.cpp | 53 +++++++++++++++++++++++++++++ Source/Parameters.h | 42 ++++++++++++++++------- Source/PluginEditor.cpp | 12 ------- Source/PluginEditor.h | 4 +++ Source/shameConfig.h | 2 +- 6 files changed, 93 insertions(+), 26 deletions(-) diff --git a/Source/AudioProcessing/AudioGraph.h b/Source/AudioProcessing/AudioGraph.h index bf0fd77..5ce9ab1 100644 --- a/Source/AudioProcessing/AudioGraph.h +++ b/Source/AudioProcessing/AudioGraph.h @@ -30,6 +30,10 @@ class AudioGraph void processGraph(juce::AudioBuffer& audioBuffer, int numChannels) { + // Update the parameters. This could be optimized by only doing this + // when parameters have actually changed. + blend.setBlendLevel(params.blend); + if (params.bypassed) return; // Apply the input drive. This is a simple linear gain. @@ -131,7 +135,7 @@ class AudioGraph break; case eHissLevel: hiss.setHissLevel(paramLevel); break; - case eBlendLevel: blend.setBlendLevel(paramLevel); break; +// case eBlendLevel: blend.setBlendLevel(paramLevel); break; case eFlangeDepth: flange.setDepth(paramLevel); break; // case eBypass: bypassGraph = (paramLevel >= 0.5f); break; case eInputDrive: setInputDrive(paramLevel); break; diff --git a/Source/Parameters.cpp b/Source/Parameters.cpp index 1ffcb10..1764428 100644 --- a/Source/Parameters.cpp +++ b/Source/Parameters.cpp @@ -10,21 +10,58 @@ static void castParameter(juce::AudioProcessorValueTreeState& apvts, Parameters::Parameters(juce::AudioProcessorValueTreeState& apvts) { + castParameter(apvts, ParameterID::input, inputParam); + castParameter(apvts, ParameterID::shame, shameParam); + castParameter(apvts, ParameterID::age, ageParam); + castParameter(apvts, ParameterID::hiss, hissParam); + castParameter(apvts, ParameterID::blend, blendParam); + castParameter(apvts, ParameterID::output, outputParam); + castParameter(apvts, ParameterID::flange, flangeParam); castParameter(apvts, ParameterID::bypass, bypassParam); + castParameter(apvts, ParameterID::link, linkParam); castParameter(apvts, ParameterID::showReels, showReelsParam); + castParameter(apvts, ParameterID::printThrough, printThroughParam); castParameter(apvts, ParameterID::environment, environmentParam); + castParameter(apvts, ParameterID::tapeType, tapeTypeParam); } juce::AudioProcessorValueTreeState::ParameterLayout Parameters::createParameterLayout() { juce::AudioProcessorValueTreeState::ParameterLayout layout; + layout.add(std::make_unique( + ParameterID::input, "Input", juce::NormalisableRange(), 0.5f)); + + layout.add(std::make_unique( + ParameterID::shame, "Shame", juce::NormalisableRange(), 0.0f)); + + layout.add(std::make_unique( + ParameterID::age, "Age", juce::NormalisableRange(), 0.0f)); + + layout.add(std::make_unique( + ParameterID::hiss, "Hiss", juce::NormalisableRange(), 0.0f)); + + layout.add(std::make_unique( + ParameterID::blend, "Blend", juce::NormalisableRange(), 1.0f)); + + layout.add(std::make_unique( + ParameterID::output, "Output", juce::NormalisableRange(), 0.5f)); + + layout.add(std::make_unique( + ParameterID::flange, "Flange", juce::NormalisableRange(), 0.0f)); + layout.add(std::make_unique( ParameterID::bypass, "Bypass", false)); + layout.add(std::make_unique( + ParameterID::link, "Link", false)); + layout.add(std::make_unique( ParameterID::showReels, "Show Reels", true)); + layout.add(std::make_unique( + ParameterID::printThrough, "Print-Through", false)); + layout.add(std::make_unique( ParameterID::environment, "Environment", @@ -38,6 +75,12 @@ juce::AudioProcessorValueTreeState::ParameterLayout Parameters::createParameterL }, 0)); + layout.add(std::make_unique( + ParameterID::tapeType, + "Tape Type", + juce::StringArray { "S-111", "A-456" }, + 0)); + return layout; } @@ -51,9 +94,19 @@ void Parameters::reset() noexcept void Parameters::update() noexcept { + input = inputParam->get(); + shame = shameParam->get(); + age = ageParam->get(); + hiss = hissParam->get(); + blend = blendParam->get(); + output = outputParam->get(); + flange = flangeParam->get(); bypassed = bypassParam->get(); + link = linkParam->get(); showReels = showReelsParam->get(); + printThrough = printThroughParam->get(); environment = EShameEnvironments(environmentParam->getIndex()); + tapeType = tapeTypeParam->getIndex(); } void Parameters::smoothen() noexcept diff --git a/Source/Parameters.h b/Source/Parameters.h index 68ef607..7b8478b 100644 --- a/Source/Parameters.h +++ b/Source/Parameters.h @@ -5,21 +5,19 @@ namespace ParameterID { + const juce::ParameterID input { "input", 1 }; + const juce::ParameterID shame { "shame", 1 }; + const juce::ParameterID age { "age", 1 }; + const juce::ParameterID hiss { "hiss", 1 }; + const juce::ParameterID blend { "blend", 1 }; + const juce::ParameterID output { "output", 1 }; + const juce::ParameterID flange { "flange", 1 }; const juce::ParameterID bypass { "bypass", 1 }; + const juce::ParameterID link { "link", 1 }; const juce::ParameterID showReels { "showReels", 1 }; + const juce::ParameterID printThrough { "printThrough", 1 }; const juce::ParameterID environment { "environment", 1 }; - -//TODO: add these parameters -// inputLevel = 1.0f; -// shame = 0.0f; -// age = 0.0f; -// hiss = 0.0f; -// blend = 0.0f; -// outputLevel = 0.0f; -// flange = 0.0f; -// tapeType -// printThrough -// linkInputOutput + const juce::ParameterID tapeType { "tapeType", 1 }; } class Parameters @@ -34,13 +32,33 @@ class Parameters void update() noexcept; void smoothen() noexcept; + float input = 0.0f; + float shame = 0.0f; + float age = 0.0f; + float hiss = 0.0f; + float blend = 0.0f; + float output = 0.0f; + float flange = 0.0f; bool bypassed = false; + bool link = false; bool showReels = true; + bool printThrough = false; EShameEnvironments environment = eEnvironmentOff; + int tapeType = 0; juce::AudioParameterBool* bypassParam; juce::AudioParameterBool* showReelsParam; juce::AudioParameterChoice* environmentParam; + juce::AudioParameterFloat* inputParam; + juce::AudioParameterFloat* shameParam; + juce::AudioParameterFloat* ageParam; + juce::AudioParameterFloat* hissParam; + juce::AudioParameterFloat* blendParam; + juce::AudioParameterFloat* outputParam; + juce::AudioParameterBool* linkParam; + juce::AudioParameterFloat* flangeParam; + juce::AudioParameterChoice* tapeTypeParam; + juce::AudioParameterBool* printThroughParam; private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Parameters) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index b1e8af9..c4bb3ab 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -63,7 +63,6 @@ KissOfShameAudioProcessorEditor::KissOfShameAudioProcessorEditor(KissOfShameAudi blendKnob.setKnobImage(blendImagePath); blendKnob.setNumFrames(65); blendKnob.setKnobDimensions(705, 455, 78, 72); - blendKnob.addListener(this); addAndMakeVisible(blendKnob); juce::String outputImagePath = GUI_PATH + "KOS_Graphics/12_alpha.png"; @@ -316,10 +315,6 @@ void KissOfShameAudioProcessorEditor::initializeLevels() // audioProcessor.setParameterNotifyingHost (KissOfShameAudioProcessor::outputParam, 0.5); audioProcessor.audioGraph.setAudioUnitParameters(eOutputLevel, 0.5); - blendKnob.setValue(1.0); -// audioProcessor.setParameterNotifyingHost (KissOfShameAudioProcessor::blendParam, 1.0); - audioProcessor.audioGraph.setAudioUnitParameters(eBlendLevel, 1.0); - linkIOButtonL.setToggleState(false, juce::dontSendNotification); linkIOButtonR.setToggleState(false, juce::dontSendNotification); linkIOButtonL.setAlpha(0.25); @@ -376,13 +371,6 @@ void KissOfShameAudioProcessorEditor::sliderValueChanged(juce::Slider* slider) audioProcessor.audioGraph.setAudioUnitParameters(eHissLevel, (float) hissKnob.getValue()); } - else if (slider == &blendKnob) - { -// audioProcessor.setParameterNotifyingHost (KissOfShameAudioProcessor::blendParam, -// (float) blendKnob->getValue()); - - audioProcessor.audioGraph.setAudioUnitParameters(eBlendLevel, (float) blendKnob.getValue()); - } else if (slider == &ageKnob) { //reelAnimation->setFramesPerSecond(ageKnob->getValue()*15 + 35); diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 470f91a..7ca13bd 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -80,6 +80,10 @@ class KissOfShameAudioProcessorEditor : public juce::AudioProcessorEditor, int priorProcessorTime; + juce::AudioProcessorValueTreeState::SliderAttachment blendAttachment { + audioProcessor.apvts, ParameterID::blend.getParamID(), blendKnob + }; + bool ignoreCallbacks = false; juce::ParameterAttachment bypassButtonAttachment; juce::ParameterAttachment showReelsAttachment; diff --git a/Source/shameConfig.h b/Source/shameConfig.h index 6607076..19873db 100644 --- a/Source/shameConfig.h +++ b/Source/shameConfig.h @@ -41,7 +41,7 @@ enum AUParameter eHurricaneSandyGlobalLevel, eHissLevel, - eBlendLevel, +// eBlendLevel, eFlangeDepth, // eBypass,