Noise / distortion after filter execution with vDSP_deq22 (biquad IIR filter)

I am working on a DSP class (obj-C ++) for Novocaine , but my filters only seem to cause signal noise / distortion.

I posted the full code and odds here: https://gist.github.com/2702844 But this basically comes down to:

// Deinterleaving...
// DSP'ing one channel:
NVDSP *handleDSP = [[NVDSP alloc] init];
[handleDSP setSamplingRate:audioManager.samplingRate];
float cornerFrequency = 6000.0f;
float Q = 0.5f;
[handleDSP setHPF:cornerFrequency Q:Q];
[handleDSP applyFilter:audioData length:numFrames];

// DSP other channel in the same way
// Interleaving and sending to audio output (Novocaine block)

See entity for full code / context.

Odds:

2012-05-15 17:54:18.858 nvdsp[700:16703] b0: 0.472029
2012-05-15 17:54:18.859 nvdsp[700:16703] b1: -0.944059
2012-05-15 17:54:18.860 nvdsp[700:16703] b2: 0.472029
2012-05-15 17:54:18.861 nvdsp[700:16703] a1: -0.748175
2012-05-15 17:54:18.861 nvdsp[700:16703] a2: 0.139942

(all divided by a0)

Since I assumed that the coefficients are in order: { b0/a0, b1/a0, b2/a0, a1/a0, a2/a0 }(see: IIR coefficients for EQ peak, how do I pass them to vDSP_deq22? )

What causes distortion / noise (filters do not work)?

+3
source share
2

: DSP I, github: https://github.com/bartolsthoorn/NVDSP , .

, woooo! : http://objective-audio.jp/2008/02/biquad-filter.html

applyFilter :

- (void) applyFilter: (float *)data frames:(NSUInteger)frames {
    /*
     The first two samples of data being passed to vDSP_deq22 have to be initialized from the previous call. So, you'd want to hold onto a float buffer and feed the tailing two samples after a vDSP_deq22 call back to the front of that array for the next time you call. (Alex Wiltschko)
     */

    // Thanks a lot to: http://objective-audio.jp/2008/02/biquad-filter.html

    // Provide buffer for processing
    float *tInputBuffer = (float*) malloc((frames + 2) * sizeof(float));
    float *tOutputBuffer = (float*) malloc((frames + 2) * sizeof(float));

    // Copy the data
    memcpy(tInputBuffer, gInputKeepBuffer, 2 * sizeof(float));
    memcpy(tOutputBuffer, gOutputKeepBuffer, 2 * sizeof(float));
    memcpy(&(tInputBuffer[2]), data, frames * sizeof(float));

    // Do the processing
    vDSP_deq22(tInputBuffer, 1, coefficients, tOutputBuffer, 1, frames);

    // Copy the data
    memcpy(data, tOutputBuffer, frames * sizeof(float));
    memcpy(gInputKeepBuffer, &(tInputBuffer[frames]), 2 * sizeof(float));
    memcpy(gOutputKeepBuffer, &(tOutputBuffer[frames]), 2 * sizeof(float));

    free(tInputBuffer);
    free(tOutputBuffer);
}

: https://github.com/bartolsthoorn/NVDSP

+9

memcpy(data, tOutputBuffer+2, frames * sizeof(float));

0

All Articles