hi, i would like to ask how do i get the audio data signal through a LPF first and a HPF after.

i have made reference to a project NVDSP, and saw that the creator has used the funtion vDSP_deq22 for the signal processing part, however, that is only through one filter. i tried to use another vDSP_deq22 function to have the processed signal to go through another filter, but it doesnt work

is there anyone who could help me with this problem?

This might save you a bit of headache:  Apple recently included (osx 10.9 SDK) a biquad in vDSP to simplify the process, so you don't need to use vDSP_deq22 anymore.  It takes care of the memory allocation/etc for you.  I messed with NVDSP, but it is objc and uses a third party audio manager, so I didn't end up using it for anything since I really only care about OSX audiounit plugins, and it seems mostly geared toward iOS.  Here are my notes from the developer conference video on the vDSP biquad (or you can just ind them in the videos section of the Apple Developer site--but the part on the biquad is only about 3 minutes of an hour long video):


WWDC 2012 session 708 Accelerate Framework

INPUT ==> Biquad 0 ==> Biquad 1 ==> Biquad N-2 ==> Biquad N-1 ==> OUTPUT

N = 10 ( means 10 stages)

each stage has 5 coefficients and 2 delays

Cascaded Biquad IIR Filter

• Setup... Operate... Destroy

#include <Accelerate/Accelerate.h>
 const int N = 10; // N = number of cascaded stages
double filterCoeffs[5 * N] = {...}; //List coefficients
float delays[2 * N + 2] = {0.f, 0.f, ..., 0.f}; // float a delay for each stage
float input[length], output[length];
// Once at start:
vDSP_biquad_Setup setup = vDSP_biquad_CreateSetup(FilterCoeffs, N);
     vDSP_biquad(setup, delays, input, 1, output, 1, length);
// Once at end:

I whipped up a quick test a while back to see if it worked plunked it into the apple 'Filter Demo' project, but I can't seem to find that project now.... but here is a snippit of how you might use it (for a single stage) with some notes since they provide no meaningful examples:


    const double a0 = ...;
    const double a1 = ...;
    const double a2 = ...;
    const double b1 = ...;
    const double b2 = ...;

    //Number of filters:
    const int N = 1;

    //Set Filter coefficients:
    double filterCoeffs[5 * N] = {a0, b1, b2, a1, a2}; // I THINK this is the  coeff order they use... might be A0, A1, A2, B1, B2??

    // float a delay for each stage (only one stage here):
    float delays[2 * N + 2] = {0.f}; 

    float input[length], output[length];

    //Once at start:
    vDSP_biquad_Setup setup = vDSP_biquad_CreateSetup(filterCoeffs, N);

    //Cascade them (only one in this test):
    vDSP_biquad(setup, delays, input, 1, output, 1, length);

    // Once at end: extern void vDSP_biquadm_DestroySetup(vDSP_biquadm_Setup __vDSP_setup)

That is obviously incomplete (and probably wrong since I can't find the working project), but should point you in the right direction.  ALSO, they changed some things since they initially patched it in and that may/may not be reflected above (also, I think there was a channel setup too... don't remember), so you may have to look up those changes on the developer site.  

I dug most info out of the vDSP.h file in the macosx10.9sdk since I could not find any info online except some basic details on the Apple developer site.  Just open it up and search for "Cascade biquadratic IIR filters" and it should take you to the usage section.

Hope that helps.  I'll post a link to the working project if I manage to dig it up.

I couldn't find the AudioUnit project, so I just re-did it for posterity since there is virtually no info on the vDSP biquad online.  It is a standard XCode5/OSX10.9 AudioUnit project based on a version of Apple's FilterDemo project (not a JUCE project) that I hacked into working with hosts that read the legacy component manager IDs.   I uploaded a copy to my band's server, so you can grab it from here: http://www.solamors.com/BiquadvDSP-alex.zip (assuming it is cool to post DL links here)

If you just want the details as opposed to the project:

--Import the "Accelerate framework into your project
--Include the accelerate header: #include <Accelerate/Accelerate.h>
--Then add this under the "private:" section of the kernel class at the top:

    // float setup delays for the biquad loop
    // array number = delays[2 * N + 2] where N=number of cascaded biquads
    // add a section to the {0.f} for each stage (i.e. 2 biquads = {0.f,0.f})
    float delays[4] = {0.f};

--And add snip out everything after these lines (except the closing bracket of course):

     // only calculate the filter coefficients if the parameters have changed from last time
     if(cutoff != mLastCutoff || resonance != mLastResonance )
     CalculateLopassParams(cutoff, resonance);
     mLastCutoff = cutoff;
     mLastResonance = resonance;

--And replace it with:

                            /* START NEW vDSP CODE*/
    // Filter coefficient array:
    // filterCoeffs array number = [5 * N] where N=number of cascaded biquads
    double filterCoeffs[5] = {mA0, mA1, mA2, mB1, mB2};
    vDSP_biquad_Setup setup = vDSP_biquad_CreateSetup(filterCoeffs, 1); //Setup
    vDSP_biquad(setup, delays, inSourceP, 1, inDestP, 1, inFramesToProcess); // Operate
    vDSP_biquad_DestroySetup(setup); // Destroy

Having vDSP do the number crunching showed about a 20% CPU speedup on my machine over the standard biquad method in the FilterDemo project... pretty nice if you have a bunch of filters in a project.