Re: Help with AudioFileGetProperty
Re: Help with AudioFileGetProperty
- Subject: Re: Help with AudioFileGetProperty
- From: Gilbert Mackall <email@hidden>
- Date: Wed, 26 Feb 2003 15:24:03 -0500
Tommy,
Thanks for the help. After a few changes here are the results of
opening an AIFF formated file created with QuickTime and the code used
to get them.
PATH = /Users/gilbertmackall/Desktop/VAM_greeting.aif
SampleRate 44100.000000
FormatID 1819304813
FormatFlags 14
BytesPerPacket 2
FramesPerPacket 1
BytesPerFrame 2
ChannelsPerFrame 1
- (IBAction)getFile:(id)sender
{
int result;
NSString *path;
FSRef fileRef;
AudioFileID fileID;
UInt32 theSize;
UInt32 isWritable;
OSStatus osStatus = noErr;
AudioStreamBasicDescription basicDescription;
NSArray *fileTypes = [NSArray
arrayWithObjects:@"AIFF",@"aif",@"AIFC",@"WAVE",@"wav",nil];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setAllowsMultipleSelection:NO];
result = [oPanel runModalForTypes:fileTypes];
if (result == NSOKButton)
{
NSArray *filesToOpen = [oPanel filenames];
path = [filesToOpen objectAtIndex:0];
printf("%s \n",[path cString]);
FSPathMakeRef([path fileSystemRepresentation],&fileRef,NULL);
AudioFileOpen(&fileRef, fsRdPerm, 0, &fileID);
osStatus = AudioFileGetPropertyInfo(fileID,
kAudioFilePropertyDataFormat, &theSize, & isWritable);
if( osStatus == noErr )
{
// basicDescription = (AudioStreamBasicDescription *
)malloc(sizeof(AudioStreamBasicDescription));
osStatus =
AudioFileGetProperty(fileID,kAudioFilePropertyDataFormat,&theSize,&basic
Description);
if( osStatus == noErr )
{
printf("SampleRate %f\n",basicDescription.mSampleRate);
printf("FormatID %ld\n",basicDescription.mFormatID);
printf("FormatFlags
%ld\n",basicDescription.mFormatFlags);
printf("BytesPerPacket
%ld\n",basicDescription.mBytesPerPacket);
printf("FramesPerPacket
%ld\n",basicDescription.mFramesPerPacket);
printf("BytesPerFrame
%ld\n",basicDescription.mBytesPerFrame);
printf("ChannelsPerFrame
%ld\n",basicDescription.mChannelsPerFrame);
}
}
}
_______________________________________________
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.