COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 05-30-2017, 06:42 AM   #1
Nowhk
Human being with feelings
 
Join Date: Mar 2016
Posts: 234
Default How do you smooth param iterating per voice->block?

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

Last edited by Nowhk; 05-30-2017 at 12:01 PM.
Nowhk is offline   Reply With Quote
Old 05-31-2017, 06:51 AM   #2
Nowhk
Human being with feelings
 
Join Date: Mar 2016
Posts: 234
Default

I've done it I create a "ramp parameter" array with blocksize lenght before iterate voices; than, for each voice, I access to it with an incremental index (which I reset to 0 when I iterate a new voice).

Thank you anyway
Nowhk is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.