Simple Objective-C Audio tutorial?

Discussion in 'Mac Programming' started by tdog, Oct 4, 2008.

  1. tdog macrumors newbie

    Joined:
    Oct 4, 2008
    #1
    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.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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.
     
  3. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #3
    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?
     
  4. iSee macrumors 68040

    iSee

    Joined:
    Oct 25, 2004
    #4
    What is the file format? Is the audio data compressed?
     

Share This Page