tags:

views:

310

answers:

1

I'm creating real-time audio sequencer app on OS X. Real-time synth part is implemented by using AURenderCallback. Now I'm making function to write rendered result to Wave File (44100Hz 16bit Stereo). Format for render-callback function is 44100Hz 32bit float Stereo interleaved.

I'm using ExtAudioFileWrite to write to file. But ExtAudioFileWrite function returns error code 1768846202;

I searched 1768846202 but I couldn't get information. Would you give me some hints?

Thank you.

Here is code.

    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;
  }
    }
A: 

Before you can do any sort of debugging, you probably need to figure out what that error message actually means. Have you tried passing that status code to GetMacOSStatusErrorString() or GetMacOSStatusCommentString()? They aren't documented so well, but they are declared in CoreServices/CarbonCore/Debugging.h.

Nik Reiman
I didn't know those methods. I'll try them. Thanks!
fish potato