• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Recording in .wav format doesn't work properly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recording in .wav format doesn't work properly


  • Subject: Re: Recording in .wav format doesn't work properly
  • From: James McCartney <email@hidden>
  • Date: Fri, 30 Oct 2009 14:27:04 -0700


On Oct 30, 2009, at 1:12 PM, Zhiye Li wrote:

I did have a ExtAudioFileDispose(extAudioFileRef) at the end of recording. But I just tried replacing it with AudioFileClose(AudioFileID) and now the recorded .wav file can be played! So it means the ExtAudioFileDispose() cannot close the file? But in the reference it says "Disposes of an extended audio file object and closes the associated file."

Thanks!

but not when ExtAudioFileWrapAudioFileID is used. from the header file:

@function   ExtAudioFileWrapAudioFileID
@abstract   Wrap an AudioFileID in an ExtAudioFileRef.
@param inFileID
The AudioFileID to wrap.
@param inForWriting
True if the AudioFileID is a new file opened for writing.
@param outExtAudioFile
On exit, a newly-allocated ExtAudioAudioFileRef.
@result An OSStatus error code.

@discussion
Allocates a new ExtAudioFileRef which wraps an existing AudioFileID. The
client is responsible for keeping the AudioFileID open until the
ExtAudioFileRef is disposed. Disposing the ExtAudioFileRef will not close
the AudioFileID when this Wrap API call is used, so the client is also
responsible for closing the AudioFileID when finished with it.




Zhiye

On Fri, Oct 30, 2009 at 12:34 PM, James McCartney <email@hidden> wrote:

You are not closing the file.

The WAV file has a data chunk size of zero. The CAF file has a data chunk size of -1.  These are definite indicators that the files were not closed. CAF is meant to be resilient to crashing while recording. A -1 data chunk size means the data chunk extends to the end of the file. So a CAF file is still valid even if its data chunk is not updated at closing time to reflect the actual size. WAV files are not legal if the data chunk size is not updated. 

On Oct 29, 2009, at 9:51 AM, Zhiye (Sterling) Li wrote:

Sorry I accidentally sent the last email while I didn't finish yet.

so, the recording part of the code is like:

    audioFormat.mSampleRate            = 44100.0;
    audioFormat.mFormatID                 = kAudioFormatLinearPCM;
    audioFormat.mFormatFlags            = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
    audioFormat.mBytesPerPacket        = 2;
    audioFormat.mFramesPerPacket    = 1;
    audioFormat.mBytesPerFrame        = 2; 
    audioFormat.mChannelsPerFrame    = 1;
    audioFormat.mBitsPerChannel        = 16;

    status = AudioFileCreateWithURL(fileURL, kAudioFileWAVEType, &audioFormat, kAudioFileFlags_EraseFile, &audioFileID);
    status = ExtAudioFileWrapAudioFileID(audioFileID, YES, &audiofile); 
    ExtAudioFileSetProperty(audiofile,kExtAudioFileProperty_ClientDataFormat,sizeof(audioFormat),&audioFormat);
    status = ExtAudioFileWriteAsync(audiofile, 0,NULL);

And in the recording callback:

    status = ExtAudioFileWriteAsync(THIS.audiofile,inNumberFrames,THIS.bufferList);

Since "status" doesn't return error anywhere, I cannot find where is wrong, but the recorded .wav file cannot even be opened by iTunes...



Zhiye


On Thu, Oct 29, 2009 at 2:32 AM, Seth Delackner <email@hidden> wrote:
How are you writing your data to the file?  AudioFileWritePackets
works fine for me.  Not sure about the data format flags you are
using.  You are trying to write mono it seems, but I've only tried
writing stereo output.  Shouldn't be an issue I would think...



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)

This email sent to email@hidden



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Recording in .wav format doesn't work properly (From: "Zhiye (Sterling) Li" <email@hidden>)
 >Re: Recording in .wav format doesn't work properly (From: Seth Delackner <email@hidden>)
 >Re: Recording in .wav format doesn't work properly (From: "Zhiye (Sterling) Li" <email@hidden>)
 >Re: Recording in .wav format doesn't work properly (From: "Zhiye (Sterling) Li" <email@hidden>)
 >Re: Recording in .wav format doesn't work properly (From: James McCartney <email@hidden>)
 >Re: Recording in .wav format doesn't work properly (From: Zhiye Li <email@hidden>)

  • Prev by Date: Re: Recording in .wav format doesn't work properly
  • Next by Date: iPhone remoteIO audio unit question
  • Previous by thread: Re: Recording in .wav format doesn't work properly
  • Next by thread: Re: Recording in .wav format doesn't work properly
  • Index(es):
    • Date
    • Thread