Tracking sample rate changes efficiently

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi,

In my plugins I generally use a private float member to store the sample rate. This member I assign to on construction and check thereafter with each call to setParameter(), that way if sample rate changes during run time or existence of the plugin instance I can propogate any changes of sample rate through my plugin where required i.e. calculation of filter coefficients. However, i think this is not an efficient way as 1. I make a call to getSampleRate() with every call to setParameter() and 2. Because sample rate does not change often so we shouldnt need to check so often.

Ideally I would like to get the sample rate just on construction of plug and be notified of sample rate chnages during lifetime of plug.

So I'm after a way of tracking sample rate. Is there a call used when sample rate is changed via host so i can watch out for it??

Thanks a lot for any info,
David

Post

implement setSampleRate() - this is called by the host, when it changes its sampleRate - at least, it should.
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

don't bother constantly checking the samplerate. it's a waste.

let the host report it to you instead,

Code: Select all

void YourPlugin::setSampleRate (float sampleRate)
{
	AudioEffectX::setSampleRate (sampleRate);
	FS=sampleRate;

//do your samplerate change related processes here

}
don't forget to include "virtual void setSampleRate (float sampleRate);" in "YourPlugin" class.

Post

Excellent! Exactly what I'm looking for!

Cheers!

Post Reply

Return to “DSP and Plugin Development”