So, I’ve extended the Synthesizer class and added a function called ‘setAttack’. This function sets the attack parameter of an ADSR-envelope I’ve added.
But, the parameter change is handled by PluginProcessor.cpp, so I’ve added the following functions below. But, somehow the compiler thinks there is no function called ‘setAttack’ inside the Synthesizer class… What’s going on? I’m using XCode in this case.
Compiler error in JuceAudioPluginDemo.cpp:
No member named ‘setAttack’ in ‘juce::SynthesiserVoice’.
I will look into the various options you mentioned.
And yes, I’m very new to c++, coming from c#/java. So some things confuse the hell out of me. But, taking babysteps and looking at references helps a lot. And also the help from the responsive Juce community
..instead, always prefer to write it like this, which reduces the scope of the pointer, making it impossible to write code that accidentally uses a null pointer:
if(Foo* f = getFoo())
// f is out-of-scope here, so a null-pointer dereference is impossible.
(This also results in more compact, cleaner code).
Thanks for pointing me to the style guide. It is always a good read.
With respect to the current problem I don’t think that the rule you cited should be applied here. After all a named pointer variable isn’t even required. The chances of unadvertedly using a dangling pointer are thus zero.
Note that the Idiom that I proposed is also present in the juce source code.
(like here: AudioProcessorValueTreeState::updateParameterConnectionsToChildTrees)