2011-04-12 45 views
7

我就需要聲學回聲消除,因此kAudioUnitSubType_VoiceProcessingIO亞型似乎是一個不錯的選擇iOS的項目。 下面是我的音頻單元描述音頻圖形初始化錯誤與kAudioUnitSubType_VoiceProcessingIO音頻IO單元亞型

//io unit description 
AudioComponentDescription ioUnitDescription; 
ioUnitDescription.componentType = kAudioUnitType_Output; 
ioUnitDescription.componentSubType = kAudioUnitSubType_VoiceProcessingIO; 
ioUnitDescription.componentManufacturer = kAudioUnitManufacturer_Apple; 
ioUnitDescription.componentFlags = 0; 
ioUnitDescription.componentFlagsMask = 0; 

而且根據我RemoteIO亞型的經驗,我啓用了輸入元素:

UInt32 enable = 1; 
AudioUnitSetProperty(ioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &enable, sizeof(enable)); 

然而,在初始化圖形聲音時,我得到的錯誤。如果VoiceProcessingIO被RemoteIO取代,那麼相同的音頻圖形效果很好。

有RemoteIO和VoiceProcessingIO需要特別注意的有什麼區別?

感謝, Chuankai

+0

抱歉上唯一的問題發表評論,但你有沒有搞清楚回聲消除?蘋果文檔一直提到具有此功能的語音處理IO,但我無法在任何地方找到它的例子。我真的很感激它 – 2012-07-25 15:31:37

回答

1

在我的經驗,VoiceProcessingIO音頻單元是更挑剔有關緩衝區的大小和採樣率。嘗試下面32000赫茲的採樣率(或許與8000赫茲開始,讓你向上的方式)和一個相當大的緩衝區大小(說2048個樣本左右)。這沒有記錄。 rdar號碼來一次我有機會提交一個。

我在設置過程中使用以下格式:

size_t bytesPerSample = sizeof(AudioSampleType); 
    AudioStreamBasicDescription canonicalFormat; 
    canonicalFormat.mSampleRate   = self.samplerate; 
    canonicalFormat.mFormatID   = kAudioFormatLinearPCM; 
    canonicalFormat.mFormatFlags  = kAudioFormatFlagsCanonical; 
    canonicalFormat.mFramesPerPacket = 1; 
    canonicalFormat.mChannelsPerFrame = 1; 
    canonicalFormat.mBitsPerChannel  = 8 * bytesPerSample; 
    canonicalFormat.mBytesPerPacket  = bytesPerSample; 
    canonicalFormat.mBytesPerFrame  = bytesPerSample;