Unable to Successfully Add Frequency Param

I think this might be due to my insufficient knowledge in DSP, but I’ve built a simple oscillator (with sine, saw, or square waves) and I successfully added an adjustable gain parameter using the AudioProcessorValueTreeState. I define the state as follows in my constructor:

, state (*this, nullptr, "STATE", {
    std::make_unique<juce::AudioParameterFloat> (juce::ParameterID("gainAdj", 1), "Gain", 0.0f, 1.0f, 0.5f) ,
   std::make_unique<juce::AudioParameterFloat> (juce::ParameterID("freqAdj", 1) , "Frequency", 30.0f, 4000.0f, 220.0f)
})

and then in processBlock i perform the following:

osc.setFrequency(state.getParameter ("freqAdj")->getValue());
osc.process(juce::dsp::ProcessContextReplacing<float>(audioBlock));

I do this same thing with my gain and it works just fine, but how come it doesn’t work when I try it with frequency? I am building a simple stand alone plugin with juce’s generic layout to handle the UI of the parameters. To give more information, all I hear when running the program is a low frequency click when first built, and then when I adjust the gain slider I’ll also hear clicks. Note that the build is successful. Thanks.

state.getParameter returns a pointer to the base AudioProcessorParameter object and the getValue method in that returns a number between 0 and 1. So your volume control happens to work by chance since 0 to 1 is a valid range for gain changes. For the frequency it doesn’t make sense since 0 Hz to 1 Hz range is too low.

To get a value in the intended parameter range for the frequency, you can try

osc.setFrequency(state.getRawParameterValue ("freqAdj")->load());