Step to step audio plugin with STK for C++

Hi… I’m becoming mad… I lost some of my work trying to add effects (STK fo C++) to a project and I can’t find the error…Bitwise I’me developing another little project, a MiniRig for guitar (inspired by the great GuitarRig).
So, I’ve lost even that…
I decided to start a new project from scratch with the audio plugin template to completely understand JUCE and STK.
I’ve implemented the STK pitch in that template (I left all as it is apart the ValueTree and two custom Knob controls and an Image GUI component to store my images).
I added the pitch.clean() method in the prepare to play and I get no more noise (Alleluia).
But I want to know:

Can I use external methods to do buffer process like:

void processBlock(AudioSampleBuffer....)
{
    processPitch(buffer);
}

void processPitch(buffer)
{
    code to process the buffer.getWritePointer();
}

And if yes (I think) where I have to put the parameters values that changes from my ValueTreeState sliders? (With the assignment of these to the STK effects like:

pitch = stk::PitShit();
pitch.setShift(pitchVal);
pitch.setEffectMix(pitchMix);

And, I have to call

pitch.clear();

every time I assign its values?

Sure you can, just make sure to provide a reference to the buffer (& symbol) rather than the object itslef, otherwise you are processing a copy of the buffer, which will be lost when returning from the “processPitch” call:

void processBlock(AudioSampleBuffer& buffer....)
{
    processPitch(buffer);
}

void processPitch (AudioSampleBuffer& buffer)
{
    // code to process the buffer.getWritePointer();
}

That’s up to you… If it is only related to the processPitch stuff, then it will be best readable to read the value inside the function, but if it is also used inside the processBlock, you could add it as argument to the processPitch method. That way you use a consistent value in the whole block.

I don’t think so, but I don’t know…

Good choice to start in smaller pieces, glad that you find your way into the stuff

Thank you… now I have more clear ideas… the noise was generated from the STK effects: they all need to be cleared after declaration and assignation in prepareToPlay but not in the procesBlock() of in the external processChains.
Now I have a nice rig with Pitch, Chorus, Delay and Reverb. No noise, clean sound.
:slight_smile:
The other aspects of the template are still a question… what I have to keep and what I can delete to have a more clean code and a less weight plugin…

1 Like

Mhm I was thinking… does anybody knows a way to implement an attack and release effects on audio buffers?
In STK there is only an ADSR filter for midi messages, instead I need to apply it to a buffer write pointer… maybe a for loop that uses a multiplier from 0 to 1 every loop?

EDIT: I need attack from 0 to 1, so the value of the slider will be in samples from 0.0 to 44100.0 and the multiplier value has to depend from the samples value… I have this idea in mind…