AudioFileCreate - fmt?
AudioFileCreate - fmt?
- Subject: AudioFileCreate - fmt?
- From: Vasudha <email@hidden>
- Date: Thu, 8 Feb 2007 02:09:41 -0800 (PST)
Hi all!
I am using the sample in the developer/examples/coreaudio/simpleSDK/convertfile/ to convert an mp3 file to wave.
I have made suitable changes to avoid command line utility and the app runs. But inspite of all permutations for the data format of my output file (kAudioFormatLinearPCM) my AudioFileCreate fails with an error - 'fmt?' I assume this refers to the format of my output file as all other parameters are fine.
Has anyone faced this before? If it works for someone please do paste the code snippet if possible!
Thanks in advance!
smriti
FILE - UseAC-AF.cpp
int ConvertFile (FSRef &inputFSRef, OSType format,
Float64
sampleRate, OSType fileType, FSRef &dirFSRef, char* fname)
{
AudioFileID infile, outfile;
OSStatus err = AudioFileOpen( &inputFSRef, fsRdPerm, 0,
&infile);
XThrowIfError (err, "AudioFileOpen" );
// get the input file format
CAStreamBasicDescri ption inputFormat;
UInt32 size = sizeof(inputFormat) ;
err = AudioFileGetPropert y(infile,
kAudioFilePropertyD ataFormat, &size, &inputFormat) ;
XThrowIfError (err, "AudioFileGetProper ty
kAudioFilePropertyD ataFormat" );
//inputFormat. mFormatID = kAudioFormatMPEGLay er3;
printf ("Source File format: "); inputFormat. Print();
CAStreamBasicDescri ption outputFormat;
// set up the output file format
/*if (format) {
printf("\nam in\n");
// need to set at least these fields for
kAudioFormatPropert y_FormatInfo
outputFormat. mFormatID = format;
outputFormat. mSampleRate = inputFormat. mSampleRate;
outputFormat.
mChannelsPerFram e =
inputFormat. mChannelsPerFram e;
// use AudioFormat API to fill out the rest.
size = sizeof(outputFormat );
err = AudioFormatGetPrope rty
(kAudioFormatProper ty_FormatInfo, 0, NULL, &size, &outputFormat) ;
} else {
outputFormat = inputFormat;
outputFormat. mSampleRate = sampleRate;
}*/
outputFormat. mSampleRate = 44100;
outputFormat. mFormatID = kAudioFormatLinearPCM;
outputFormat. mFormatFlags =
kLinearPCMFormatFla gIsSignedInteger ;
outputFormat. mChannelsPerFram e = 2;
outputFormat. mBitsPerChannel = 16;
outputFormat. mFramesPerPacket = 1;
outputFormat. mBytesPerFrame = 4;
outputFormat. mBytesPerPacket = 4;
// create the AudioConverter
AudioConverterRef converter;
err = AudioConverterNew( &inputFormat, &outputFormat,
&converter);
//printf("AudioConv erterNew err %4.4s X %d\n", &err, err,
err);
XThrowIfError (err, "AudioConverterNew" );
// get the actual output format
//size = sizeof(outputFormat );
//err = AudioConverterGetPr operty(converter ,
kAudioConverterCurr entOutputStreamD escription, &size, &outputFormat) ;
//XThrowIfError (err, "get
kAudioConverterCurr entOutputStreamD escription" );
printf ("Dest File format: "); outputFormat. Print();
CFStringRef cfName = CFStringCreateWithC String (NULL, fname,
kCFStringEncodingUT F8);
FSRef fsRef;
CFShow(cfName) ;
err = AudioFileCreate( &dirFSRef, cfName, fileType,
&outputFormat, 0, &fsRef, &outfile);
CFRelease (cfName);
XThrowIfError (err, "AudioFileCreate" );
DEBUG LOG-
HERE-wavSource File format:
AudioStreamBasicDes cription: 2 ch, 44100
Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152
frames/packet, 0 bytes/frame
Dest File format: AudioStreamBasicDes cription: 2 ch, 44100 Hz, 'lpcm'
(0x00000004) 16-bit little-endian signed integer
outfile.wav
error 'fmt?': AudioFileCreate
terminate called after throwing an instance of 'CAXException'
UseAC-AF has exited due to signal 6 (SIGABRT).
Never Miss an Email
Stay connected with Yahoo! Mail on your mobile.
Get started! _______________________________________________
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