Re: CAF file, testing chunk types?
Re: CAF file, testing chunk types?
- Subject: Re: CAF file, testing chunk types?
- From: Darren Minifie <email@hidden>
- Date: Wed, 30 Sep 2009 20:15:51 -0700
Oh ok i think I understand. Thanks.
I have one other related question about CAF files and endian-ness:
I have a method that looks at an NSData object (which is a CAF file in memory). The method finds the chunk type and stores it as a string. In the spec, the chunk type is defined as a UInt32, and is a seuqence of 4 chars. Here is my method which produces correct output on a little endian machine:
-(NSString*)fileType{
if(!fileType){
char type [5];
type[4] = '\0';
memcpy(type, (char*)[fileData bytes], 4);
fileType = [[NSString stringWithCString:type encoding:NSASCIIStringEncoding] retain];
}
return fileType;
}
If CAF files are in big-endian format, why does this method produce the correct result? In other words why don't have i have to do a ntohl() in this case to flip the enianness, like i have to in the case of reading the chunk length etc.
Thanks again.
On Wed, Sep 30, 2009 at 7:57 PM, William Stewart
<email@hidden> wrote:
'desc' is an "OSType" - its really just an int (4 bytes), and using these 4 char codes is a way to create unique numbers that are somewhat human readable.
In a CAF file, these are all "big endian" order, so on an Intel machine you will have to flip the endian order (as intel CPUs are of course little endian). Then you end up with a number, and you can do a numerical comparison between that native-endian number and the various CAF chunk types until you fine it (a case statement is probably what you will end up writing)
Bill
On Sep 30, 2009, at 6:28 PM, Darren Minifie wrote:
Hi everyone
I apologize for this "noob" question but I've never run into it before (and I am sure to receive a 'google it' response, but haven't found what i'm looking for).
I am writing a CAF file parser for fun. I have parsed the four character strings that describe the chunk types, and have them stored as NSStrings. I want to be able to output a more meaningful name however. In CAFFile.h, an enum is defined that describes the chunk types:
// CAF Chunk Types
enum {
kCAF_StreamDescriptionChunkID = 'desc',
kCAF_AudioDataChunkID = 'data',
kCAF_ChannelLayoutChunkID = 'chan',
kCAF_FillerChunkID = 'free',
etc....
}
My question is: what are the datatypes of this enum? i know that single characters in single quotes are chars (e.g 'a', 'b'), and string literals are in double quotes ("a", "b"), but what are these and how to I test them against the strings that I have parsed?
Thanks for any help.
--
Darren Minifie
Computer Science Masters Candidate
University of Victoria, BC. Canada
My Rants:
www.noisyair.com
My Band:
www.ohsnapmusic.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
This email sent to email@hidden
--
Darren Minifie
Computer Science Masters Candidate
University of Victoria, BC. Canada
My Rants:
www.noisyair.comMy Band:
www.ohsnapmusic.com
_______________________________________________
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