OS Xでリアルタイムオーディオシーケンサーアプリケーションを作成しています。 リアルタイムシンセパートはAURenderCallback
を使用して実装されています。 レンダリングした結果をウェーブファイル(44100Hz 16bit Stereo)
に書き込む機能を作っています。 レンダリングコールバック関数の形式は44100Hz 32bit floatステレオインターリーブされています。オーディオユニットとファイルへの書き込み
私はファイルに書き込むのにExtAudioFileWrite
を使用しています。 ExtAudioFileWrite
関数はエラーコード1768846202
を返します。
1768846202
を検索しましたが、情報を取得できませんでした。 ヒントを教えてください。
ありがとうございます。
ここはコードです。
outFileFormat.mSampleRate = 44100;
outFileFormat.mFormatID = kAudioFormatLinearPCM;
outFileFormat.mFormatFlags =
kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
outFileFormat.mBitsPerChannel = 16;
outFileFormat.mChannelsPerFrame = 2;
outFileFormat.mFramesPerPacket = 1;
outFileFormat.mBytesPerFrame =
outFileFormat.mBitsPerChannel/8 * outFileFormat.mChannelsPerFrame;
outFileFormat.mBytesPerPacket =
outFileFormat.mBytesPerFrame * outFileFormat.mFramesPerPacket;
AudioBufferList *ioList;
ioList = (AudioBufferList*)calloc(1, sizeof(AudioBufferList)
+ 2 * sizeof(AudioBuffer));
ioList->mNumberBuffers = 2;
ioList->mBuffers[0].mNumberChannels = 1;
ioList->mBuffers[0].mDataByteSize = allocByteSize/2;
ioList->mBuffers[0].mData = ioDataL;
ioList->mBuffers[1].mNumberChannels = 1;
ioList->mBuffers[1].mDataByteSize = allocByteSize/2;
ioList->mBuffers[1].mData = ioDataR;
...
while (1) {
//Fill buffer by using render callback func.
RenderCallback(self, nil, nil, 0, frames, ioList);
//i want to create one sec file.
if (renderedFrames >= 44100) break;
err = ExtAudioFileWrite(outAudioFileRef, frames , ioList);
if (err != noErr){
NSLog(@"ERROR AT WRITING TO FILE");
goto errorExit;
}
}
。私はそれらを試してみます。ありがとう! –