gpt4 book ai didi

iPhone aurioTouch 示例 : Remove DC

转载 作者:行者123 更新时间:2023-12-03 18:43:15 25 4
gpt4 key购买 nike

我正在查看 iPhone aurioTouch 示例,特别是以下代码:

static OSStatus PerformThru(
void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData)
{
aurioTouchAppDelegate *THIS = (aurioTouchAppDelegate *)inRefCon;
OSStatus err = AudioUnitRender(THIS->rioUnit, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData);
if (err) { printf("PerformThru: error %d\n", (int)err); return err; }

// Remove DC component
for(UInt32 i = 0; i < ioData->mNumberBuffers; ++i)
THIS->dcFilter[i].InplaceFilter((SInt32*)(ioData->mBuffers[i].mData), inNumberFrames, 1);

// ...

}

在文件 aurioTouchAppDelegate.mm 中。

初学者问题:“去除直流分量”有什么作用?任何有关它的教程文章的指针都会受到赞赏。

预先感谢您的帮助。

最佳答案

以下是 InplaceFilter 方法的代码:

void DCRejectionFilter::InplaceFilter(SInt32* ioData, UInt32 numFrames, UInt32 strides) 
{
register SInt32 y1 = mY1, x1 = mX1;
for (UInt32 i=0; i < numFrames; i++)
{
register SInt32 x0, y0;
x0 = ioData[i*strides];
y0 = smul32by16(y1, mA1);
y1 = smulAdd32by16(x0 - x1, mGain, y0) << 1;
ioData[i*strides] = y1;
x1 = x0;
}
mY1 = y1;
mX1 = x1;
}

基本上,代码正在执行 high-pass filter在音频上去除频谱的直流分量,也称为 DC offset 。滤波器的系数(维基百科文章中的 alpha)在代码中默认设置为 0.975,DC 去除滤波器的典型值在 0.9 到 1.0 之间。如果您调整采样率,那么您可能需要调整该系数,但我不会太担心。

关于iPhone aurioTouch 示例 : Remove DC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3070322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com