Skip to content

Commit

Permalink
add parameters for everything
Browse files Browse the repository at this point in the history
  • Loading branch information
hollance committed Apr 11, 2024
1 parent 2f2e37d commit e62923d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 26 deletions.
6 changes: 5 additions & 1 deletion Source/AudioProcessing/AudioGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class AudioGraph

void processGraph(juce::AudioBuffer<float>& 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.
Expand Down Expand Up @@ -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;
Expand Down
53 changes: 53 additions & 0 deletions Source/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<juce::AudioParameterFloat>(
ParameterID::input, "Input", juce::NormalisableRange<float>(), 0.5f));

layout.add(std::make_unique<juce::AudioParameterFloat>(
ParameterID::shame, "Shame", juce::NormalisableRange<float>(), 0.0f));

layout.add(std::make_unique<juce::AudioParameterFloat>(
ParameterID::age, "Age", juce::NormalisableRange<float>(), 0.0f));

layout.add(std::make_unique<juce::AudioParameterFloat>(
ParameterID::hiss, "Hiss", juce::NormalisableRange<float>(), 0.0f));

layout.add(std::make_unique<juce::AudioParameterFloat>(
ParameterID::blend, "Blend", juce::NormalisableRange<float>(), 1.0f));

layout.add(std::make_unique<juce::AudioParameterFloat>(
ParameterID::output, "Output", juce::NormalisableRange<float>(), 0.5f));

layout.add(std::make_unique<juce::AudioParameterFloat>(
ParameterID::flange, "Flange", juce::NormalisableRange<float>(), 0.0f));

layout.add(std::make_unique<juce::AudioParameterBool>(
ParameterID::bypass, "Bypass", false));

layout.add(std::make_unique<juce::AudioParameterBool>(
ParameterID::link, "Link", false));

layout.add(std::make_unique<juce::AudioParameterBool>(
ParameterID::showReels, "Show Reels", true));

layout.add(std::make_unique<juce::AudioParameterBool>(
ParameterID::printThrough, "Print-Through", false));

layout.add(std::make_unique<juce::AudioParameterChoice>(
ParameterID::environment,
"Environment",
Expand All @@ -38,6 +75,12 @@ juce::AudioProcessorValueTreeState::ParameterLayout Parameters::createParameterL
},
0));

layout.add(std::make_unique<juce::AudioParameterChoice>(
ParameterID::tapeType,
"Tape Type",
juce::StringArray { "S-111", "A-456" },
0));

return layout;
}

Expand All @@ -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
Expand Down
42 changes: 30 additions & 12 deletions Source/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
12 changes: 0 additions & 12 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/shameConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum AUParameter

eHurricaneSandyGlobalLevel,
eHissLevel,
eBlendLevel,
// eBlendLevel,
eFlangeDepth,

// eBypass,
Expand Down

0 comments on commit e62923d

Please sign in to comment.