Hi all,
I've created a list of my custom params (AdvancedParameter). Each param value can be changed by GUI and/or automations, so I need to smooth every param with a basic
smooth algo on every sample:
Code:
AdvancedParameter **ppParameter = mAdvancedParameters.GetList();
for (int i = 0; i < mAdvancedParameters.GetSize(); i++, ppParameter++) {
AdvancedParameter *pParameter = *ppParameter;
pParameter->SmoothParameter();
}
My whole plugin is poly, using voices.
This is the way I iterate audio buffer (per voice, than per sample block on each voice):
Code:
void MainIPlug::ProcessDoubleReplacing(double **inputs, double **outputs, int nFrames) {
double *left = outputs[0];
double *right = outputs[1];
memset(left, 0, nFrames * sizeof(double)); // outputLeft[i] = inputs[0][i];
memset(right, 0, nFrames * sizeof(double)); // outputRight[i] = inputs[1][i];
// buffer
int remainingSamples = nFrames;
while (remainingSamples > 0) {
// events
pMidiHandler->Process();
pVoiceManager->Process();
int blockSize = remainingSamples;
blockSize = pMidiHandler->GetSamplesTillNextEvent(blockSize);
blockSize = pVoiceManager->GetSamplesTillNextEvent(blockSize);
// voices
for (int voiceIndex = 0; voiceIndex < PLUG_VOICES_BUFFER_SIZE; voiceIndex++) {
Voice &voice = pVoiceManager->mVoices[voiceIndex];
if (!voice.mIsPlaying) {
continue;
}
double *blockLeft = left;
double *blockRight = right;
int nbSamples = blockSize;
while (nbSamples > 0) {
// control rate
if (mControlRateIndex-- == 0) {
mControlRateIndex = PLUG_CONTROL_RATE - 1;
// smooth stuff that require lot of CPU
}
// audio
double sampleLeft = 0;
double sampleRight = 0;
pOscillator1->Process(voice, &sampleLeft, &sampleRight);
// apply "smoothed params"
*blockLeft++ += sampleLeft * pParam1->GetValue();
*blockRight++ += sampleRight * pParam1->GetValue();
// increments
nbSamples--;
}
}
// fx (ProcessBlock)
remainingSamples -= blockSize;
left += blockSize;
right += blockSize;
pMidiHandler->Flush(blockSize);
}
}
The fact is: where do I "smooth" these params?
I can't to it within nbSamples, because I'm inside a voice. So it will smooth "nicely" the first voice (or part of it, if require more than nbSamples samples). The other voices will be already smoothed by the first voices.
The same if I do outside the block iteration, within the voice block for example: it will be smoothed only per voice, not per samples.
The param are of course global (not poly), shared across all voices.
How do you usually manage this kind of process within IPlug (or audio plugin in general)?
Thanks