iOS音频单元:何时使用AUGraph是必要的? [英] iOS Audio Units : When is usage of AUGraph's necessary?

查看:424
本文介绍了iOS音频单元:何时使用AUGraph是必要的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对iOS编程完全陌生(我更像是一个Android人......)并且必须构建一个处理音频DSP的应用程序。 (我知道这不是接近iOS开发的最简单方法;)

I'm totally new to iOS programing (I'm more an Android guy..) and have to build an application dealing with audio DSP. (I know it's not the easiest way to approach iOS dev ;) )

该应用程序需要能够接受以下输入:

The app needs to be able to accept inputs both from :

1-内置麦克风
2- iPod库

1- built-in microphone 2- iPod library

然后过滤器可能会应用于输入声音,结果是被输出:

Then filters may be applied to the input sound and the resulting is to be outputed to :

1-发言人
2-记录到文件

1- Speaker 2- Record to a file

我的问题是以下:为了能够将多个过滤器应用于输入,是否需要AUGr​​aph,或者通过处理具有不同渲染回调的样本来应用这些不同的效果?

My question is the following : Is an AUGraph necessary in order to be able for example to apply multiple filters to the input or can these different effects be applied by processing the samples with different render callbacks ?

如果我使用AUGraph,我需要:每个输入1个音频单元,输出1个音频单元和每个效果/滤波器1个音频输入吗?

If I go with AUGraph do I need : 1 Audio Unit for each input, 1 Audio Unit for the output and 1 Audio Input for each effect/filter ?

和最后,如果我不这样做,我可能只有1个音频单元并重新配置它以选择源/目的地?

And finally if I don't may I only have 1 Audio Unit and reconfigure it in order to select the source/destination ?

非常感谢您的回答!我迷失了这些东西...

Many thanks for your answers ! I'm getting lost with this stuff...

推荐答案

如果你愿意,你可能确实使用渲染回调在音频单元是伟大的(有些东西,我在这里还没有说NDA等,我已经说了太多,如果你有权访问iOS 5 SDK我建议你看看。)

You may indeed use render callbacks if you so wished to but the built in Audio Units are great (and there are things coming that I can't say here yet under NDA etc., I've said too much, if you have access to the iOS 5 SDK I recommend you have a look).

您可以在不使用 AUGraph 的情况下实现您希望的行为,但是建议您这样做,因为它需要经常处理引擎盖下的东西,节省您的时间和精力。

You can implement the behavior you wish without using AUGraph, however it is recommended you do as it takes care of a lot of things under the hood and saves you time and effort.

来自音频单元托管指南( iOS开发人员库)


AUGraph 类型增加了线程安全性到音频单元的故事:它使您能够动态地重新配置处理链。例如,您可以安全地插入均衡器,甚至可以在播放音频时交换混音器输入的不同渲染回调函数。实际上, AUGraph 类型提供了iOS中唯一的API,用于在音频应用中执行此类动态重新配置。

The AUGraph type adds thread safety to the audio unit story: It enables you to reconfigure a processing chain on the fly. For example, you could safely insert an equalizer, or even swap in a different render callback function for a mixer input, while audio is playing. In fact, the AUGraph type provides the only API in iOS for performing this sort of dynamic reconfiguration in an audio app.

选择设计模式(iOS开发人员库)详细介绍了如何选择如何实现音频单元环境。从设置音频会话,图形和配置/添加单元,编写回调。

Choosing A Design Pattern (iOS Developer Library) goes into some detail on how you would choose how to implement your Audio Unit environment. From setting up the audio session, graph and configuring/adding units, writing callbacks.

至于您在图表中想要的音频单元,除了您已经说明的内容之外,您还需要一个 MultiChannel调音台(参见使用特定音频单元(iOS开发者库))混合两个音频输入,然后将调音台连接到输出单元。

As for which Audio Units you would want in the graph, in addition to what you already stated, you will want to have a MultiChannel Mixer Unit (see Using Specific Audio Units (iOS Developer Library)) to mix your two audio inputs and then hook up the mixer to the Output unit.

或者,如果您在不使用AUGraph的情况下直接进行此操作,以下代码是自行连接音频单元的示例。 (来自构建音频单元应用程序(iOS开发人员库)

Alternatively, if you were to do it directly without using AUGraph, the following code is a sample to hook up Audio units together yourself. (From Constructing Audio Unit Apps (iOS Developer Library))


您也可以建立和断开音频$ b之间的连接通过使用音频单元属性机制直接$ b单位。为此,
使用 AudioUnitSetProperty 函数以及
kAudioUnitProperty_MakeConnection 属性,如图所示在清单2-6 中。
此方法要求您为每个连接定义一个AudioUnitConnection
结构作为其属性值。

You can, alternatively, establish and break connections between audio units directly by using the audio unit property mechanism. To do so, use the AudioUnitSetProperty function along with the kAudioUnitProperty_MakeConnection property, as shown in Listing 2-6. This approach requires that you define an AudioUnitConnection structure for each connection to serve as its property value.



/*Listing 2-6*/
AudioUnitElement mixerUnitOutputBus  = 0;
AudioUnitElement ioUnitOutputElement = 0;

AudioUnitConnection mixerOutToIoUnitIn;
mixerOutToIoUnitIn.sourceAudioUnit    = mixerUnitInstance;
mixerOutToIoUnitIn.sourceOutputNumber = mixerUnitOutputBus;
mixerOutToIoUnitIn.destInputNumber    = ioUnitOutputElement;

AudioUnitSetProperty (
    ioUnitInstance,                     // connection destination
    kAudioUnitProperty_MakeConnection,  // property key
    kAudioUnitScope_Input,              // destination scope
    ioUnitOutputElement,                // destination element
    &mixerOutToIoUnitIn,                // connection definition
    sizeof (mixerOutToIoUnitIn)
);

这篇关于iOS音频单元:何时使用AUGraph是必要的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆