このセットアップでオーディオを再生および録音する AUGraph があります。
RemoteIO -> -> RemoteIO
Mulichannel Mixer -> variSpeed
Read Callback -> -> Write Callback
私の問題は、iOS 5.x で kAudioUnitSubType_Varispeed が StreamFormat を受け入れなかったことです。iOS 6 で動作します。正しい StreamFormat がないと、AUGraph は実行されませんでした。
すべての入力と出力に同じ StreamFormat を設定します。
memset(&_audioFormat, 0, sizeof(_audioFormat));
UInt32 propertySize = sizeof(AudioStreamBasicDescription);
CheckError(AudioUnitGetProperty(self.io, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &_audioFormat, &propertySize), "Couldn't get audio Format for io input");
_audioFormat.mChannelsPerFrame = 1;
_audioFormat.mSampleRate = self.hardwareSampleRate;
// set audio Format for io
CheckError(AudioUnitSetProperty(self.io, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for output");
CheckError(AudioUnitSetProperty(self.io, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for input");
// set audio Format for mixer
CheckError(AudioUnitSetProperty(self.mixer, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for mixer 0");
CheckError(AudioUnitSetProperty(self.mixer, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for mixer 1");
CheckError(AudioUnitSetProperty(self.mixer, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kOutputBus, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for mixer output");
// set audio Format for speed
CheckError(AudioUnitSetProperty(self.speed, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for speed input");
CheckError(AudioUnitSetProperty(self.speed, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for speed output");
iOS 5.x の CAShow:
AudioUnitGraph 0x6CC000:
Member Nodes:
node 1: 'auou' 'rioc' 'appl', instance 0x18cc2a0 O I
node 2: 'aumx' 'mcmx' 'appl', instance 0x455680 O I
node 3: 'aufc' 'vari' 'appl', instance 0x450270 O I
Connections:
node 1 bus 1 => node 2 bus 1 [ 1 ch, 22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 2 bus 0 => node 3 bus 0 [ 2 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 3 bus 0 => node 1 bus 0 [ 1 ch, 22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
Input Callbacks:
{0x53b5d, 0x454cd0} => node 2 bus 0 [1 ch, 22000 Hz]
CurrentState:
mLastUpdateError=0, eventsToProcess=F, isRunning=F
iOS 6.x の CAShow:
AudioUnitGraph 0x388000:
Member Nodes:
node 1: 'auou' 'rioc' 'appl', instance 0x1f03b1e0 O I
node 2: 'aumx' 'mcmx' 'appl', instance 0x1f05fd60 O I
node 3: 'aufc' 'vari' 'appl', instance 0x1e590b90 O I
Connections:
node 1 bus 1 => node 2 bus 1 [ 1 ch, 22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 2 bus 0 => node 3 bus 0 [ 1 ch, 22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
node 3 bus 0 => node 1 bus 0 [ 1 ch, 22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
Input Callbacks:
{0xe9b5d, 0x1e58e4e0} => node 2 bus 0 [1 ch, 22000 Hz]
CurrentState:
mLastUpdateError=0, eventsToProcess=F, isRunning=F
速度ノードが iOS 5.x で StreamFormat を受け入れなかったのはなぜですか :( ? 私を助けてくれる人はいますか? ありがとう。