Re: mp3 recording
Re: mp3 recording
- Subject: Re: mp3 recording
- From: "Jay Ridgeway" <email@hidden>
- Date: Tue, 13 Jan 2004 11:08:16 -0500 (EST)
- Organization: AOL
What is the AudioStreamBasicDescription look like for AAC? I get the
following error (with the following code) while trying to get info on an
AAC file converted from an mp3 using iTunes. Is this an issue with
support via the converter API's but not the file API's? Ultimately, I
want to write a sound recorder that writes compressed files.
I have to say it has been difficult figuring out the CoreAudio API's due
to lack of simple examples (like the code below) but they seem to be
very well thought out and well structured; with the exception of
resusing arguments for input and output.
Thanks,
Jay Ridgeway
(** Error **)
Error(1954115647): 'typ?' -> aufileinfo.c: 40
(** Code **)
#include <AudioToolbox/AudioFile.h>
#include <AudioToolbox/AudioConverter.h>
#include <AudioToolbox/AudioFormat.h>
#include <libkern/OSTypes.h>
/*
*
* Prints out a stream description given an audio file.
*
* gcc aufileinfo.c -framework AudioToolbox -framework CoreFoundation
-framework Carbon -o aufileinfo
*
*/
#define HorkOnError(err) \
if(err) {\
printf("Error(%ld): '%.*s' -> %s: %d\n", err, sizeof(err), (char*)
&err, __FILE__, __LINE__);\
fflush(stdout);\
return err; \
}
int
main(int argc, char **argv)
{
OSStatus err;
AudioFileID outAudioFile;
FSRef inFileRef; // What's wrong with char buffer?
UInt32 size;
char code[5];
AudioStreamBasicDescription absd;
if (argc != 2) {
printf("usage: %s <audio file>\n", argv[0]);
exit(1);
}
FSPathMakeRef((const UInt8 *) argv[1], &inFileRef, NULL);
err = AudioFileOpen(&inFileRef, fsRdPerm, 0, &outAudioFile);
HorkOnError(err);
size = sizeof(absd);
err = AudioFileGetProperty(outAudioFile,
kAudioFilePropertyDataFormat, &size, &absd);
HorkOnError(err);
memcpy(code, &(absd.mFormatID), 4);
code[5] = '\0';
printf("mFormatID: '%s'\n", code);
printf("mFormatFlags: %d\n", absd.mFormatFlags);
printf("mBytesPerPacket: %d\n", absd.mBytesPerPacket);
printf("mSampleRate: %.2f\n", absd.mSampleRate);
printf("mBytesPerPacket: %d\n", absd.mBytesPerPacket);
printf("mFramesPerPacket: %d\n", absd.mFramesPerPacket);
printf("mBytesPerFrame: %d\n", absd.mBytesPerFrame);
printf("mChannelsPerFrame: %d\n", absd.mChannelsPerFrame);
printf("mBitsPerChannel: %d\n", absd.mBitsPerChannel);
return 0;
}
email@hidden wrote on 1/12/04, 7:22 PM:
>
Message: 3
>
Cc: email@hidden
>
From: William Stewart <email@hidden>
>
Subject: Re: mp3 encoding
>
Date: Mon, 12 Jan 2004 15:37:46 -0800
>
To: Berend Schmid <email@hidden>
>
>
There is no MP3 encoder that is shipped with the OS. There is an AAC
>
one however that can be accessed with this API (and the format type for
>
this is 'aac ')
>
>
Bill
--
bStandards are a vehicle of communication for producers and users. They
serve as a common language, defining quality and establishing safety
criteria. Costs are lower if procedures are standardized. Training is
simplified. And consumers accept products more readily when they can be
judged on intrinsic merit.b
-- American Society of Testing and Materials (ASTM)
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.