vDSP_biquadm API

77 views
Skip to first unread message

Luigi Castelli

unread,
Oct 14, 2015, 6:29:32 PM10/14/15
to PerfOpt-Dev
Hi there,

I am currently experimenting with the vDSP_biquadm functions and I am having a couple of questions/doubts.

I thoroughly studied the vDSP.h header file and the BiquadSample/main.c file.
However - being a new API - there is not much information available online, other than the aforementioned sources.

In my specific example I am using the vDSP_biquadm interface in a real-time audio application.
All the functions in the API work as expected and make sense to me. The speed gains are significant.

In my process method I provide standard arrays of input and output buffers.
Samples in each buffer are arranged in a deinterleaved fashion.

I am using vDSP_biquadm_SetCoefficientsDouble() to assign new coefficients to the biquadm object.
The code I use is something like:

{
    if (mUpdateCoeffs) {
        vDSP_biquadm_SetCoefficientsDouble(mSetup, mCoeffs, 0, 0, mMaxSections, mMaxChannels);
        mUpdateCoeffs = false;
    }
    vDSP_biquadm(mSetup, (const float **)inputBuffers, 1, outputBuffers, 1, numFramesToProcess);
}

Note that in the above code all the coefficients get directly assigned to the biquadm object without any kind of interpolation.
Also note that I am dumping all the coefficients at once (all sections, all channels)
I am aware this is not the most efficient way, and I should only assign the coefficients corresponding to the section(s) and channel(s) that have changed. However this is just a quick solution to check that I am using the API correctly. The above code works and produces the expected output.

Now, I want to implement coefficient smoothing...
I am thinking all I need to do is to substitute the above with the following:

{
    if (mUpdateCoeffs) {
        vDSP_biquadm_SetTargetsDouble(mSetup, mCoeffs, mInterpRate, mInterpThreshold, 0, 0, mMaxSections, mMaxChannels);
        mUpdateCoeffs = false;
    }
    vDSP_biquadm(mSetup, (const float **)inputBuffers, 1, outputBuffers, 1, numFramesToProcess);
}

However this does not work. Although the filter coefficients still get somehow updated I get horrible zipper noise all over the place.
I should add that sometimes the vDSP_biquadm_SetTargetsDouble() function gets called again with new targets when the old ones are still being interpolated. I am hoping that inside the API there are provisions to deal with this case.

The problem I am having is that I don’t really understand what the interpolation rate and threshold mean. 
For instance, let’s say that I would like to specify the interpolation time in ms, so with a sample rate of 44100Hz, if I choose 100ms as my interpolation time I should be able to interpolate all the filter coefficients over 4410 samples. However I am not sure how the rate argument relates to time. Also as far as the interpolation threshold goes, I would like the coefficients to get interpolated until they exactly match the targets, so should I choose 0.0 as the value for the threshold argument? How does the rate argument relates to time in samples?

Can anybody point out what I am misunderstanding and explain how to use this API to accomplish real-time filter coefficients interpolation?
Thanks a lot for any help.

- Luigi Castelli

Justin Voo

unread,
Oct 15, 2015, 11:43:05 AM10/15/15
to perfoptimi...@lists.apple.com

Reduced message size so it would send. Please see below. 

Sent from my iPhone

On Oct 14, 2015, at 4:29 PM, Justin Voo <jv...@apple.com> wrote:

Hello,

The interpolation rate is used to update the coefficients after each sample as follows, from sample ‘i’ to ‘i+1’ for example:

Coefficient[i+1] = Coefficient[i] * InterpolationRate + Target * (1 - InterpolationRate)

‘Coefficient’ is any filter coefficient with a corresponding target value of ‘Target’.  The interpolation rate is ‘InterpolationRate’ .  

This applies to all of the coefficients and they may be updated separately and/or together in order to bring all coefficients to within the threshold of their targets.  The above relationship and the specified threshold are respected, but the number of samples over which coefficients are updated may vary.

When executing vDSP_biquadm, after calling vDSP_biquadm_SetTargets*, for a sufficient number of samples, the coefficients will be within the specified threshold of the targets.  The threshold must be a positive non-zero value.  If you want to set the exact value of the coefficients you should use vDSP_biquadm_SetCoefficients*.

Hi there,

I am currently experimenting with the vDSP_biquadm functions and I am having a couple of questions/doubts.

I thoroughly studied the vDSP.h header file and the BiquadSample/main.c file.
However - being a new API - there is not much information available online, other than the aforementioned sources.

...

Justin Voo

unread,
Oct 17, 2015, 1:52:19 PM10/17/15
to Luigi Castelli, perfoptimi...@lists.apple.com

On Oct 17, 2015, at 10:39 AM, Justin Voo <jv...@apple.com> wrote:

Hi Luigi,

That is correct, interpolation rates closer to 1 should result in more smoothing.  Your calculation is correct, although more samples may be computed under coefficient update (but never fewer).  

Can you please file a bug report with crash logs along with a small test case which reproduces the crash?

Thanks,
- Justin


Luigi Castelli

unread,
Oct 18, 2015, 1:02:13 PM10/18/15
to Justin Voo, perfoptimi...@lists.apple.com
Hi Justin,

thanks for taking the time to look at it.
Yes, I will file a bug report as you said.

Cheers.

- Luigi
Reply all
Reply to author
Forward
0 new messages