播放和录制音频Iphone,AudioUnit

时间:2013-10-30 14:57:56

标签: ios iphone audio record audiounit

我想添加到此http://www.cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html 例如recordCallBack:

我补充说:

recordingCallback

static OSStatus recordingCallback(void *inRefCon, 
                              AudioUnitRenderActionFlags *ioActionFlags, 
                              const AudioTimeStamp *inTimeStamp, 
                              UInt32 inBusNumber, 
                              UInt32 inNumberFrames, 
                              AudioBufferList *ioData) {

NSlog(@"recordingCallback");
...

return noErr;
}

并添加到输出音频单元(toneUnit)配置。

// Set input callback
input.inputProc = recordingCallback;
input.inputProcRefCon = self;
err = AudioUnitSetProperty(toneUnit,
                              kAudioOutputUnitProperty_SetInputCallback,
                              kAudioUnitScope_Global,
                              1,
                              &input,
                              sizeof(input));

...

err = AudioUnitSetProperty (toneUnit,
                            kAudioUnitProperty_StreamFormat,
                            kAudioUnitScope_Output,
                            1,
                            &streamFormat,
                            sizeof(AudioStreamBasicDescription));

iphone要求允许使用麦克风,但我的录音回调从未被称为

更新解决方案

AudioUnitAddRenderNotify(
iOUnit,
&recordingCallback,
self
);

0 个答案:

没有答案