我正在OS X上創建實時音頻音序器應用程序。 實時合成器部分使用AURenderCallback
實現。 現在我正在將渲染結果寫入Wave File (44100Hz 16bit Stereo)
。 渲染回調函數的格式是44100Hz 32位浮點立體交錯。音頻單元和寫入文件
我正在使用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;
}
}
我不知道這些方法。我會嘗試他們。謝謝! – 2009-09-05 02:03:15