Iphone 如何在apple aurio Touch(例如音频会话)应用程序中静音输出?
我已经根据苹果公司的 示例应用程序。但我不知道如何设置音频单元或音频 会话不播放音频输入的声音。现在在麦克风里吹的时候, 我能听到iphone扬声器的呼吸声。如何预防 以下是苹果的音频会话初始化代码:Iphone 如何在apple aurio Touch(例如音频会话)应用程序中静音输出?,iphone,session,audio,toolbox,Iphone,Session,Audio,Toolbox,我已经根据苹果公司的 示例应用程序。但我不知道如何设置音频单元或音频 会话不播放音频输入的声音。现在在麦克风里吹的时候, 我能听到iphone扬声器的呼吸声。如何预防 以下是苹果的音频会话初始化代码: XThrowIfError(AudioSessionInitialize(NULL, NULL, rioInterruptionListener, self), "couldn't initialize audio session"); XThrowIfEr
XThrowIfError(AudioSessionInitialize(NULL, NULL, rioInterruptionListener, self), "couldn't initialize audio session");
XThrowIfError(AudioSessionSetActive(true), "couldn't set audio session active\n");
UInt32 audioCategory = kAudioSessionCategory_RecordAudio;
XThrowIfError(AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory), "couldn't set audio category");
XThrowIfError(AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, propListener, self), "couldn't set property listener");
Float32 preferredBufferSize = .005;
XThrowIfError(AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, sizeof(preferredBufferSize), &preferredBufferSize), "couldn't set i/o buffer duration");
UInt32 size = sizeof(hwSampleRate);
XThrowIfError(AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareSampleRate, &size, &hwSampleRate), "couldn't get hw sample rate");
XThrowIfError(SetupRemoteIO(rioUnit, inputProc, thruFormat), "couldn't setup remote i/o unit");
dcFilter = new DCRejectionFilter[thruFormat.NumberChannels()];
UInt32 maxFPS;
size = sizeof(maxFPS);
XThrowIfError(AudioUnitGetProperty(rioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, &maxFPS, &size), "couldn't get the remote I/O unit's max frames per slice");
fftBufferManager = new FFTBufferManager(maxFPS);
l_fftData = new int32_t[maxFPS/2];
XThrowIfError(AudioOutputUnitStart(rioUnit), "couldn't start remote i/o unit");
size = sizeof(thruFormat);
XThrowIfError(AudioUnitGetProperty(rioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, &thruFormat, &size), "couldn't get the remote I/O unit's output client format");
多谢
他的回答是:
AURIOTouch使用单个回调将音频从输入传递到输出。所以最简单的事情就是零
在完成呼吸检测后,取出ioData结构
比如:
for (UInt32 i=0; i < inData->mNumberBuffers; i++)
memset(inData->mBuffers[i].mData, 0, inData->mBuffers[i].mDataByteSize);
(UInt32 i=0;i
memset(inData->mBuffers[i].mData,0,inData->mBuffers[i].mDataByteSize);
或者您可以看看CAPlayThrough示例,该示例对输入和输出有单独的回调。@DesprateLearner请查看我自己的答案。对我来说很有效。所以我假设你调用了:void silenedata(AudioBufferList*inData){for(UInt32 I=0;I