Reputation: 413
i'm just trying to capture the mic and save data to wav file ! and here is the code:
AudioFileID FileID=remoteIOplayer->mixAudioFile;
if (inBusNumber == 16){
AudioUnitRender(audioUnit, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData);
OSStatus result = AudioFileWritePackets(FileID, false, (inNumberFrames * 4), NULL, mixpacketNum, &inNumberFrames, ioData->mBuffers[i].mData);
if (result != noErr){
NSLog(@"Error Writing");
mixpacketNum += inNumberFrames;
}
}
and i created the file correctly with the following format that also used to capture the mic:
audioFormat.mSampleRate = 44100.00;
audioFormat.mFormatID = kAudioFormatLinearPCM;
audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 1;
audioFormat.mBitsPerChannel = 16;
audioFormat.mBytesPerPacket = 2;
audioFormat.mBytesPerFrame = 2;
the error is result OSStatus -38 fnopnerr (file not open)
Upvotes: 0
Views: 1066
Reputation: 40430
I'm guessing that your call to open the audio file either failed or wasn't done before rendering started. What does your call to AudioFileCreateWithURL
look like?
Upvotes: 1