• 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
Writing to Stereo Wav File (AudioUnitSampleType/8.24 format)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Writing to Stereo Wav File (AudioUnitSampleType/8.24 format)


  • Subject: Writing to Stereo Wav File (AudioUnitSampleType/8.24 format)
  • From: David Blake <email@hidden>
  • Date: Thu, 13 Jun 2013 02:43:01 +1000

Hi,

In my iPhone app I am writing the product of my rendercallback in an offline render to an external file. All works fine exporting to a mono AudioSampleType (SInt16) file to both WAV and AAC. I have recently added stereo ability and want to be able to export stereo files also. I have made all the necessary updates and when writing the AAC file, stereo works fine. However when attempting to write to a WAV file (using a stereo AudioUnitSampleType fixed 8.24 format ASBD) I get an error (1718449215 / kAudioFileUnsupportedDataFormatError) when trying to create the container for the output file before the render takes place. The relevant code is as follows:


     fileTypeID = kAudioFileWAVEType;
     if (enableStereo) { // If setup for Stereo:
            size_t bytesPerSample = sizeof (AudioUnitSampleType);

destFormat.mFormatID          = kAudioFormatLinearPCM;                    destFormat.mFormatFlags       = kAudioFormatFlagsAudioUnitCanonical;            destFormat.mBytesPerPacket    = bytesPerSample;            destFormat.mFramesPerPacket   = 1;
destFormat.mBytesPerFrame     = bytesPerSample;            destFormat.mChannelsPerFrame  = 2;                    // 2 indicates stereo            destFormat.mBitsPerChannel    = 8 * bytesPerSample;            destFormat.mSampleRate        = graphSampleRate;

        }

        else { // If configured for mono, do this (works just fine)

            fileTypeID = kAudioFileWAVEType;

            destFormat = int16StreamFormat;

/* for clarities sake, this is defined as:

int16StreamFormat.mSampleRate = graphSampleRate;
int16StreamFormat.mFormatID = kAudioFormatLinearPCM;
int16StreamFormat.mFormatFlags = kAudioFormatFlagsCanonical ;
int16StreamFormat.mFramesPerPacket = 1;
int16StreamFormat.mChannelsPerFrame = 1;
int16StreamFormat.mBitsPerChannel = 16;
int16StreamFormat.mBytesPerPacket = 2;
int16StreamFormat.mBytesPerFrame = 2;
*/

        }


//Then attempts to create the file, status = 1718449215 or kAudioFileUnsupportedDataFormatError is returned when trying to set the stereo format 

   status = ExtAudioFileCreateWithURL(destinationURL, fileTypeID, &destFormat, NULL, kAudioFileFlags_EraseFile, &exportFileRef);

  if (status) NSLog(@"1. Error creating file with URL: %ld", status);


The error would suggest that a fixed point 8.24 cannot be stored in a wav file? Is this really the case? I have also tried setting the fileTypeID to AudioFileCAFType but get the same error.

Can anyone point me in the right direction? What is the right combination of fileTypeId and ASBD to write a LPCM 8.24 fixed point stereo file ?

Thanks for any insight you guys can provide.

Cheers,
Dave


 _______________________________________________
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

  • Follow-Ups:
    • Re: Writing to Stereo Wav File (AudioUnitSampleType/8.24 format)
      • From: Richard Dobson <email@hidden>
    • Re: Writing to Stereo Wav File (AudioUnitSampleType/8.24 format)
      • From: David Blake <email@hidden>
  • Prev by Date: AUInitializeGraph() crash
  • Next by Date: Can you help me? I need you to answer a little survey about audio software. Is my homework for my class of technology entrepreneurship. Thanks
  • Previous by thread: AUInitializeGraph() crash
  • Next by thread: Re: Writing to Stereo Wav File (AudioUnitSampleType/8.24 format)
  • Index(es):
    • Date
    • Thread