views:

1278

answers:

2

I need to load sound files to a Cocoa-based OpenAL app.

Progress:

  • The OpenAL utility function alutLoadWAVFile has been deprecated; the alut header is no longer included in Mac OS X SDKs. According to the TechNotes, the actual code is still there for binary compatibility. However, if I attempt to add a declaration for the function, the code will compile but the linker will abort, complaining that the symbol for alutLoadWAVFile could not be found. (I am linking to the OpenAL.framework).

  • Yet, Apple OpenAL sample code still uses this symbol. When I Clean the sample code project, it compiles and links just fine. Yet there is no declaration of the function to be found. (Side question: how can it build and link, then?)

So, I found some code by George Warner at Apple, containing replacement functions for alutCreateBufferFromFile and alutLoadMemoryFromFile. Although capable of creating an OpenAL buffer directly from most any kind of audio file, the code appears to support only 8bit mono sound files. 16bit stereo or mono 44khz files result in a nasty hissing sound and clipping. (The files are ok; Quicktime plays them just fine.)

Thus, my question: can someone please point me to some .wav loading code/help for Cocoa/Carbon, suitable for use with an OpenAL Buffer? Thankyou.

A: 

This may be an obvious suggestion, but since you didn't mention it: have you tried the library at http://www.openal.org/ as suggested in Apple's technote?

As for how the sample code links and builds, it's not finding a prototype (if you turn on -Wall, you'll get an implicit function declaration warning), but OpenAL.framework--at least in the SDK they are using in the sample project--does in fact export _alutLoadWAVFile, which you can check with nm. What's the exact link error you get, and what SDK are you using?

smorgan
Thanks for the help.I'm not using the library itself, because Apple's sample code does not use it. Instead, the sample code uses the 10.4 SDK, and links to System/Library/Frameworks/OpenAL.framework. I am doing the same.Only diff I could see between projects is that my xcode compatibility is 3.1, theirs is 2.4.So, I commented out my <OpenAL/al.h> and <OpenAL/alc.h> lines, and instead used the the old OpenAL headers. I restored alutLoadWAVFile back in to my code, and voila! I now have wav support.It's a workaround, but I'll take it!Cheers.
SirRatty
+1  A: 

Use the AudioFileReadBytes function from Audio Services. Examples can be found in the Finch sound engine, see the Sound+IO category.

zoul