Thanks, not sure on how to pass them from the prepareToPlay(), as I’m just starting with c++,
as I understand it they are already class members of APVTS no?
any guidance would be highly appreciated at this point
BTW I declared them as floats - because otherwise I’m getting an error - Cannot initialize a parameter of type 'float' with an lvalue of type 'std::__1::atomic<float>
The best approach is to use the parameter itself as member. They are members of the APVTS, that’s correct. But the getRawParameterValue() and the getParameter() as well do a lookup that is avoidable by having a member variable that is set only once in the constructor.
class MyAudioProcessor : public juce::AudioProcessor
{
// ...your other code...
private:
juce::AudioParameterFloat* drive = nullptr;
juce::AudioParameterFloat* range = nullptr;
};
// in the constructor:
MyAudioProcessor::MyAudioProcessor()
: // all the stuff
{
// ... all your other initialisations ...
drive = dynamic_cast<juce::AudioParameterFloat*>(apvts.getParameter ("DRIVE"));
jassert (drive); // if this fires you don't have a parameter of that type with that ID
range = dynamic_cast<juce::AudioParameterFloat*>(apvts.getParameter ("RANGE"));
jassert (range); // if this fires you don't have a parameter of that type with that ID
}
// in processBlock or wherever you need it:
auto driveValue = drive->get(); // returns the current float value
auto rangeValue = range->get(); // returns the current float value
Daniel always has good and helpful ideas. So you can study his example.
I was going to illustrate my way of doing it, but I think if you can understand Daniel’s approach you will be able to get things working as you require.