iPhone/iPad Audio Unit 2012/05/19

来源:互联网 发布:江湖跑腿系统源码 编辑:程序博客网 时间:2024/05/17 04:17


1. 使用Audio Unit采集声音 (耗时2:30小时)

* 似乎不推荐

There are two other main design patterns for audio units hosting. To record or analyze audio, create an input-only app with a render callback function. The callback function is invoked by your application, and it in turn invokes the render method of the Remote I/O unit’s input element. However, in most cases, a better choice for an app like this is to use an input audio queue object (of type AudioQueueRef instantiated using the AudioQueueNewInputfunction), as explained in Audio Queue Services Programming Guide. Using an audio queue object provides a great deal more flexibility because its render callback function is not on a realtime thread.


Q:似乎若真要做,似乎意思是没有call back把captured audio传过来,需要自己实现类似机制?


* 设置input element的output scope,render callback function:没有用!

    // for output ? call back render 

  AURenderCallbackStruct callback_struct;

callback_struct.inputProc = renderCallback;

callback_struct.inputProcRefCon =self;

ASSERT_OK(AudioUnitSetProperty(audioUnit, 

                                   kAudioUnitProperty_SetRenderCallback,//

                                  //kAudioOutputUnitProperty_SetInputCallback,

                                   kAudioUnitScope_Output,// output callback handler 

                                  1,// for input bus ( bus/element 1) 

                                   &callback_struct, 

                                  sizeof(callback_struct)));


注:callback未被执行!

* 另一种可能性:

在output element的input scope callback中去拿到这个数据???

与此同时,disable output element的output scope?