【问题标题】:Noise/distortion after doing filters with vDSP_deq22 (biquad IIR filter)使用 vDSP_deq22(双二阶 IIR 滤波器)进行滤波器后的噪声/失真
【发布时间】:2012-05-23 04:45:27
【问题描述】:

我正在为Novocaine 开发一个 DSP 类 (obj-c++),但我的过滤器似乎只会对信号造成噪声/失真。

我在这里发布了我的完整代码和系数:https://gist.github.com/2702844 但它基本上归结为:

// 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)

查看要点以获取完整代码/上下文。

系数:

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

(全部除以a0

因为我假设系数的顺序是:{ b0/a0, b1/a0, b2/a0, a1/a0, a2/a0 }(参见:IIR coefficients for peaking EQ, how to pass them to vDSP_deq22?

是什么导致失真/噪音(过滤器不起作用)?

【问题讨论】:

  • “失真/噪声”不是很具描述性。你有一些图可以添加到你的帖子中以获得一些简单的测试波形吗? (例如冲动)。另外,在您提到的上一个问题中,我猜测哪个是a,在您的情况下哪个是b。编号也可能是从后到前。
  • 这个日本网站还声明系数的顺序是b0, b1, b2, a1, a2:objective-audio.jp/2008/02/biquad-filter.html

标签: c++ objective-c signal-processing accelerate-framework vdsp


【解决方案1】:

更新:我推荐大家使用我在 github 上发布的 DSP 类:https://github.com/bartolsthoorn/NVDSP 它可能会为你节省不少工作。

搞定了,哇!日本人万岁: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

【讨论】:

【解决方案2】:

复制数据:

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

它会起作用的

【讨论】:

    猜你喜欢
    • 2016-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-05
    • 2015-09-02
    • 2014-04-26
    • 2012-11-01
    • 2012-04-06
    相关资源
    最近更新 更多