I'm trying to read/write sample rate information from AIFF files and came across these two handy functions for converting to/from IEEE 80-bit Extended number format;
http://www.onicos.com/staff/iz/formats/ieee.c
However, when I use the function the numbers don't come out right. For example, the bytes for a 44100Hz sample is (if you read it in a hex editor);
but if I use the ConvertToExtended function like this (I put the casts in just in case but it actually has no effect on the result);
and then read the numbers stored in byteBuffer I get;
Now I only vaguely understand the conversion process so I'm having a hard time working through the function to find out why it's not coming out correct. Can anyone decode the function (in the link) and suggest why, maybe, it won't work in Objective-C? I copy-and-pasted it straight into my code and it compiles fine.
Or alternatively, is there a way of working with IEEE 80-bit Extended numbers in the iPhone API?
Thanks,
Neil
http://www.onicos.com/staff/iz/formats/ieee.c
However, when I use the function the numbers don't come out right. For example, the bytes for a 44100Hz sample is (if you read it in a hex editor);
Code:
40 0D AC 44 00 00 00 00 00 00
Code:
ConvertToIeeeExtended((double)44100, (char *)byteBuffer);
and then read the numbers stored in byteBuffer I get;
Code:
40 [B]0E[/B] AC 44 00 00 00 00 00 00
Now I only vaguely understand the conversion process so I'm having a hard time working through the function to find out why it's not coming out correct. Can anyone decode the function (in the link) and suggest why, maybe, it won't work in Objective-C? I copy-and-pasted it straight into my code and it compiles fine.
Or alternatively, is there a way of working with IEEE 80-bit Extended numbers in the iPhone API?
Thanks,
Neil