Help Please - failure in creating audio file.
Help Please - failure in creating audio file.
- Subject: Help Please - failure in creating audio file.
- From: wm schauweker <email@hidden>
- Date: Thu, 14 Jan 2010 19:13:43 -0800 (PST)
I would be most grateful for any guidance anyone could offer.
o On iPhone, using SDK 3.1.2, testing in emulator.
o I am trying to use Core Audio to create a file from audio sample data.
oThis is in the nature of an "export" routine - exporting audio data that was originally taken from an Audio Unit and stashed in a "sample" file.
o Now, I want to read the sample file and convert to .wav format.
After much hacking I have the following working to the point that I can create an AudioConverter. However the CreatAudioFile function is failing with a fmt? error. (I had the whole copy sequence working earlier, but the the formats were bogus - I specified only one channel, but the sample file format is two-channel mono - buffer of sound, buffer of silence, ... .)
Here
are the ASBDs I am defining, and a snippet of the code in question:
// Specify sample format. (AudioUnit input samples - 8.24 uninterleaved, 2 channels)
inputFormat.mSampleRate = 44100.0;
inputFormat.mFormatID = kAudioFormatLinearPCM;
inputFormat.mFramesPerPacket = 1;
inputFormat.mChannelsPerFrame = 2;
inputFormat.mBytesPerFrame = 4;
inputFormat.mBytesPerPacket = 4;
inputFormat.mBitsPerChannel = 32;
inputFormat.mReserved = 0;
inputFormat.mFormatFlags =
kLinearPCMFormatFlagIsSignedInteger
|
kLinearPCMFormatFlagIsPacked |
kAudioFormatFlagIsNonInterleaved;
// Specify output recording format. (16-bit samples, noninterleaved.)
outputFormat.mSampleRate = 44100.0;
outputFormat.mFormatID = kAudioFormatLinearPCM;
outputFormat.mFramesPerPacket = 1;
outputFormat.mChannelsPerFrame = 2;
outputFormat.mBytesPerFrame = 2;
outputFormat.mBytesPerPacket = 2;
outputFormat.mBitsPerChannel = 16;
outputFormat.mReserved = 0;
outputFormat.mFormatFlags =
kLinearPCMFormatFlagIsSignedInteger |
kLinearPCMFormatFlagIsPacked |
kAudioFormatFlagIsNonInterleaved;
// Create AudioConverter
XThrowIfError(AudioConverterNew(&inputFormat, &outputFormat, &converter), "Exporter: Error creating AudioConverter");
// Open output file.
CFURLRef exportURL = CFURLCreateFromFileSystemRepresentation(NULL, (UInt8*)exportPath_, strlen(exportPath_), false);
/** This is the call that is failing **/
XThrowIfError(AudioFileCreateWithURL(exportURL,
kAudioFileWAVEType,
&outputFormat,
kAudioFileFlags_EraseFile,
&outputFile), "Exporter: Error opening export output file");
_______________________________________________
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