Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tdog

macrumors newbie
Original poster
Oct 4, 2008
1
0
My Obj-C skills are quite rusty but I have a rather simple situation where I need to be able to read in an audio file (8 bit) and write out the integer data for the samples into an asci file.

As I start to look through the "getting started with audio" on the mac developer site I see that most all the examples are geared toward more practical concerns.

Could someone point me to a tutorial which simply demonstrates how to open an audio file and examine the data? Thanks for any suggestions you may have.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
I don't think this is going to be easy. Audio stuff on the Mac is complicated and done mostly with CoreAudio, which is a C-based API.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
Yes, you will have to use CoreAudio, or if it's uncompressed audio and you know the format and offsets you could possibly just walk pointers through the file and read raw bytes but that could be messy. CoreAudio is not really that terrible to work with a lot of the time. I taught myself a lot about it and got a fairly complex audio application up and running from knowing nothing about it.

That said, I wish they would write a Cocoa wrapper for the whole thing. There is just a lot of stupid hoops you need to jump through. For example, to read a value for an object (structure in CoreAudio), you can't just read the value, you first have to call a function that gets the size of the return value, then allocate memory for the variable to hold the value, then call another function to read the value, then deallocate the memory. You'll also need to translate things that CoreAudio doesn't understand about Cocoa like strings (with encodings), file URLs, and soforth. So it's kind of a PITA but you can learn it.

Another option might be to use some other language and/or libraries to deal with this. I don't know what, maybe Python, OpenAL, Java, or some UNIX lib someone has written?
 

iSee

macrumors 68040
Oct 25, 2004
3,540
272
What is the file format? Is the audio data compressed?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.