Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c kAudioUnitSubType_NBandEQ是如何工作的?或使用含奴佛卡因的DSP配方均衡?_Objective C_Ios_Signal Processing_Core Audio - Fatal编程技术网

Objective c kAudioUnitSubType_NBandEQ是如何工作的?或使用含奴佛卡因的DSP配方均衡?

Objective c kAudioUnitSubType_NBandEQ是如何工作的?或使用含奴佛卡因的DSP配方均衡?,objective-c,ios,signal-processing,core-audio,Objective C,Ios,Signal Processing,Core Audio,我正在尝试制作一个10波段均衡器,kAudioUnitSubType_NBandEQ音频单元似乎是一个不错的选择,但苹果的文档中没有介绍如何设置/配置它 我已经连接了节点,但在尝试将EQNode与iONode(输出)连接时出错: 我如何把效果变成一个工作的10波段均衡器 更新: 一个可行的DSP公式也是一个解决方案,任何想法!那些DSP公式相当复杂 更新2: 我更喜欢使用DSP公式,因为这比编程音频节点更干净/更小 更新3: “多类型均衡器单元(属于kAudioUnitSubType_NBand

我正在尝试制作一个10波段均衡器,kAudioUnitSubType_NBandEQ音频单元似乎是一个不错的选择,但苹果的文档中没有介绍如何设置/配置它

我已经连接了节点,但在尝试将EQNode与iONode(输出)连接时出错:

我如何把效果变成一个工作的10波段均衡器

更新: 一个可行的DSP公式也是一个解决方案,任何想法!那些DSP公式相当复杂

更新2: 我更喜欢使用DSP公式,因为这比编程音频节点更干净/更小

更新3: “多类型均衡器单元(属于kAudioUnitSubType_NBandEQ子类型)提供一个均衡器,可配置为“多类型均衡器单元滤波器类型”(第68页)中所述的任何一种类型。” 资料来源: 但仍然没有例子


重要更新(17/05):我建议大家使用我在github上发布的DSP类:它可能会为您节省很多工作。这将使开发n波段均衡器或任何类型的音频滤波器变得轻而易举。

10波段均衡器可配置如下

converterNode->eqNode->converterNode->ioNode。 请参考下面的示例代码。这里我使用了iPodEQ单元。将iPodEQunit格式规格更换为10频段均衡器

AUNode outputNode;
AUNode iPodTimeNode;
AUNode converterNode;
AUNode converterNode2;

AudioUnit converterAU;
AudioUnit converterAU2;

printf("create client format ASBD\n");

// client format audio going into the converter
mClientFormat.SetCanonical(1, false); 
mClientFormat.mSampleRate = kGraphSampleRate;
mClientFormat.Print();

printf("create output format ASBD\n");
CAStreamBasicDescription localOutput;
localOutput.SetAUCanonical(2, false);
localOutput.mSampleRate = kGraphSampleRate;

// output format
mOutputFormat.SetCanonical(1, false); 
mOutputFormat.mSampleRate = kGraphSampleRate;
mOutputFormat.Print();

OSStatus result = noErr;

printf("-----------\n");
printf("new AUGraph\n");

// create a new AUGraph
result = NewAUGraph(&mGraph);
if (result) { printf("NewAUGraph result %ld %08X %4.4s\n", result,
                     (unsigned int)result, (char*)&result); return; }

// create three CAComponentDescription for the AUs we want in the graph

// output unit
CAComponentDescription output_desc(kAudioUnitType_Output,
                                   kAudioUnitSubType_GenericOutput,
                                   kAudioUnitManufacturer_Apple);

// iPodTime unit
CAComponentDescription iPodTime_desc(kAudioUnitType_FormatConverter,
                                     kAudioUnitSubType_AUiPodTimeOther,
                                     kAudioUnitManufacturer_Apple);


// AU Converter
CAComponentDescription converter_desc(kAudioUnitType_FormatConverter,
                                      kAudioUnitSubType_AUConverter,
                                      kAudioUnitManufacturer_Apple);

printf("add nodes\n");

// create a node in the graph that is an AudioUnit, using the supplied
// AudioComponentDescription to find and open that unit
result = AUGraphAddNode(mGraph, &output_desc, &outputNode);

result = AUGraphAddNode(mGraph, &iPodTime_desc, &iPodTimeNode);

result = AUGraphAddNode(mGraph, &converter_desc, &converterNode);

result = AUGraphAddNode(mGraph, &converter_desc, &converterNode2);

// connect a node's output to a node's input
// converter -> iPodTime ->converter-> output

result = AUGraphConnectNodeInput(mGraph, converterNode2, 0, iPodTimeNode, 0);

result = AUGraphConnectNodeInput(mGraph, iPodTimeNode, 0, converterNode, 0);

result = AUGraphConnectNodeInput(mGraph, converterNode, 0, outputNode, 0);



// open the graph -- AudioUnits are open but not initialized
// (no resource allocation occurs here)
result = AUGraphOpen(mGraph);


// grab audio unit instances from the nodes
result = AUGraphNodeInfo(mGraph, converterNode, NULL, &converterAU);
result = AUGraphNodeInfo(mGraph, converterNode2, NULL, &converterAU2);
result = AUGraphNodeInfo(mGraph, iPodTimeNode, NULL, &mIPodTime);
result = AUGraphNodeInfo(mGraph, outputNode, NULL, &mOutputUnit);

//Get EQ unit format
UInt32 size ;
CAStreamBasicDescription eqDesc;
AudioUnitGetProperty(mIPodTime, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &eqDesc, &size);
eqDesc.Print();


// setup render callback struct
AURenderCallbackStruct rcbs;
rcbs.inputProc = &renderInput;
rcbs.inputProcRefCon = &mUserData;

printf("set AUGraphSetNodeInputCallback\n");

// set a callback for the specified node's specified input bus (bus 1)
result = AUGraphSetNodeInputCallback(mGraph, converterNode2, 0, &rcbs);

//SetFormat
result = AudioUnitSetProperty(converterAU2, kAudioUnitProperty_StreamFormat,
                              kAudioUnitScope_Input, 0, &mClientFormat, sizeof(mClientFormat));
result = AudioUnitSetProperty(converterAU2, kAudioUnitProperty_StreamFormat,
                              kAudioUnitScope_Output, 0, &eqDesc, sizeof(eqDesc));

printf("set converter input bus %d client kAudioUnitProperty_StreamFormat\n", 0);

// set the input stream format, this is the format of the audio
// for the converter input bus (bus 1)
result = AudioUnitSetProperty(converterAU, kAudioUnitProperty_StreamFormat,
                              kAudioUnitScope_Input, 0, &localOutput, sizeof(localOutput));


// in an au graph, each nodes output stream format (including sample rate)
// needs to be set explicitly this stream format is propagated to its
// destination's input stream format

printf("set converter output kAudioUnitProperty_StreamFormat\n");

// set the output stream format of the converter
result = AudioUnitSetProperty(converterAU, kAudioUnitProperty_StreamFormat,
                              kAudioUnitScope_Output, 0, &mOutputFormat, sizeof(mOutputFormat));

result = AudioUnitSetProperty(mOutputUnit, kAudioUnitProperty_StreamFormat,
                              kAudioUnitScope_Output, 0, &mOutputFormat, sizeof(mOutputFormat));

// set the output stream format of the iPodTime unit
result = AudioUnitSetProperty(mIPodTime, kAudioUnitProperty_StreamFormat,
                              kAudioUnitScope_Output, 0, &localOutput, sizeof(localOutput));


printf("AUGraphInitialize\n");
// add a render notification, this is a callback that the graph will call every time the graph renders
// the callback will be called once before the graph’s render operation, and once after the render operation is complete

我是奴佛卡因的创造者,我用它用vDSP制作了200多个频带的均衡器

我正在考虑切换到NBandEQ音频单元,但我有一个vDSP_deq22的工作解决方案


vDSP_deq22使用二阶IIR过滤器一次过滤一个样本的数据。你可以在musicdsp.org上找到二阶巴特沃斯系数,或者更一般地通过谷歌搜索。如果您有权获得副本,Matlab也会为您计算它们。我使用了musicdsp.org。您需要创建10个vDSP_deq22滤波器,通过每个滤波器运行音频,将该频带乘以指定的增益,然后将滤波器组中所有滤波器的输出相加到输出音频中

似乎有~0人在整个互联网上使用过它。祝你好运。谢谢,一定要有人第一个问起它,我知道有些人用过它,比如写新有声书的人!在实现音频节点时,我发现这个苹果文档非常有用:@tiltem我建议您从开始,现在就添加NVDSP文件。然后,您可以轻松添加NVDSP文件,以添加创建均衡器所需的DSP功能。好主意,添加一个样本项目,虽然,我会这样做今晚或明天!(观看NVDSP repo以了解变化)@tiltem抱歉延迟,我添加了一个10波段均衡器的示例!我认为这将包括您所需要的。这不只是告诉我如何“连接”节点,而不是实际配置NBandEQ单元吗?嗨,我已经尝试了几天,这就是我得到的:它只会产生咔嗒声。您能给我举个例子,说明如何使用vDSP_deq22将特定频带复制到浮点*缓冲区中吗?我会给悬赏点,当我有这些可用!传递给vDSP_deq22的前两个数据样本必须根据上一次调用进行初始化。因此,您希望在vDSP_deq22调用后保留一个浮点缓冲区,并将尾部的两个样本反馈到该数组的前端,以便下次调用。是的,谢谢,我已经知道了如何计算系数,只剩下一个问题了!我必须按什么顺序传递系数?(为什么是5个系数而不是6,我有a0,a1,a2,b0,b1,b2,所以实际上有6个)我把最后一个问题变成了一个关于堆栈溢出的新问题: