iOS 提供了三个 I/O unit : Remote I/O unit 、Voice-Processing unit 和 Generic Output unit 。大多数audio unit 的应用都是使用 remote I/O unit 连接到输入和输出硬件,并实时访问传入和传出的音频采样。对于VoIP应用程序,Voice-Processing I / O unit 扩展 Remote I / O unit, 加入回音消除、音质处理等多种功能。如果要把音频送回应用程序,而不是输出的音频硬件,使用 Generic Output unit。


Remote I/O Unit


Remote I/O unit (subtype kAudioUnitSubType_RemoteIO) 连接硬件设备的I/O,实时地输入和输出音频数据。用于播放、录音、实时音频的输入和输出(不消除回声)。

设备的音频硬件在Remote I/O Unit的两侧设置音频流的格式。可以通过“Understanding Where and How to Set Stream Formats”了解如何设置音频流格式。audio unit 提供了audio converter ,用于转换硬件格式和应用的音频格式。

官方示例aurioTouch 实现了如何使用这个音频单元。

下图详细描述 Remote I/O unit 的使用


110714570.png


Voice-Processing I / O Unit


Voice-Processing I / O unit (subtype kAudioUnitSubType_VoiceProcessingIO) 在 Remote I/O unit 的基础上增加了回声抑制、双向双工通信、自动增益校正,调整语音处理质量,和静音。这个Voice-Processing I / O unit 用于VoIP应用程序。


Generic Output Unit

Generic Output unit (subtype kAudioUnitSubType_GenericOutput )是把audio graph 输出的音频数据送回app,用于离线的音频处理。像其它audio unit一样,Generic Output unit 实现audio graph 音频格式与用户需要的音频格式之间的转换。