[Openal] New member - Compiling OpenAL example on Macintosh

Cara Quinn caraquinn at caraquinn.com
Fri Mar 13 19:44:12 PDT 2009


   Eric, Wow!  Thanks for the wealth of leads / info!  :)

   -am looking at the OpenAL example right now.

   As per my note, you gave me just what I needed!  :)  I simply  
needed the proper type for 'device' so the ALCdevice* pointer was part  
of the missing link that the docs didn't mention and I couldn't seem  
to locate. eek!  -either poor docs or my poor lil blonde head!  lol!

   anyway, the only issue I have now is the loading / unloading as you  
also cover in your note.

   I'm actually wanting to stay cross-platform here so I'm thinking  
I'll use SDL, as the project I'm working on already has SDL support.   
(I'm trying to use OpenAL for a 'proof-of-concept') as we're not  
certain if SDL will ultimately perform the way we'd like.

   -Thus my rather haphazard intro to OpenAL!  :)

   So, just to be clear, you're saying that there is actually no  
current way with the default install of OpenAL on Mac to load / unload  
files using straight OpenAL?


   Anyway, -one more curious question


   according to the 1.1 spec, the old alutLoadWAVFile() and  
alutUnloadWAV() methods seem to be changed to loadWAVFile() and  
unloadWAV(), respectively.  If Apple really is adhering to 1.1 then  
why in the world aren't these two methods supported?
   :)  It doesn't make sense to me.

   Also, are these two methods actually still in the alut.h library,  
even though the names have been changed?


   Once again, Eric, thanks so very much for your help.  You rock!
   :)

   Have a terrific weekend!


Smiles,

Cara  :)
---
View my Online Portfolio at:
http://www.onemodelplace.com/CaraQuinn

On Mar 13, 2009, at 5:40 PM, E. Wing wrote:



On Fri, Mar 13, 2009 at 3:08 PM, Cara Quinn <caraquinn at caraquinn.com>  
wrote:
  Hello all, -just joined this list, and have a newby question which  
I'm betting has been asked bunches o' times before.  So my apologies  
in advance!  :)

  I'm working in C++ and am trying to compile a basic OpenAL example  
via the command line with GCC on a Mac running Leopard 10.6.

  I'm obviously getting errors having to do with alut.h not being  
found and thusly, all of the alut functions not being available.

  NOw, I know that technically alut is no longer supported in OpenAL  
1.1 and Apple is adhering to that spec so I'm not surprised I can't  
compile, but my question is this;  What in the world am I to do about  
it?!  :)

Don't use alut :)

You describe two different reasons you need alut:
1) To initialize OpenAL
2) To load a WAV file

For (1), you can do everything with OpenAL directly. You need to open  
a device, and then create a context in the device you opened to render  
sound into.

So typically (ignoring error checking):
ALCdevice* openal_device = alcOpenDevice(NULL);
ALCcontext* openal_context = alcCreateContext(openal_device, 0);

// you may also want to explicitly make the context current to make  
sure it is active
alcMakeContextCurrent(openal_context);


For (2), there are lots of different things you can do.
- You can use Core Audio's native audio file loaders
- You can go find a 3rd party audio file loader
- You can write your own
- You can cheat and exploit symbols that are still in Apple's OpenAL  
framework but are publicly not exposed in headers

For 3rd party, you have a lot of options. I personally like SDL_sound  
because it handles a lot of different file formats with a single API  
and is cross-platform. There is a 3rd party re-implementation of alut  
you can also use, but it is API/ABI incompatible with Apple's OpenAL  
framework for technical reasons so you must rename all the function  
names in the library to use it safely. You can also code directly to a  
specific codec, e.g. ogg vorbis. I've seem some tutorials that do this  
with OpenAL.

For cheating, you can try to access the old alut symbols in Apple's  
OpenAL framework.  For backwards compatibility, Apple left the old  
symbols in the framework to not break legacy programs. But this is  
also the reason the new 3rd party alut isn't compatible. The old alut  
API was different on every single platform, and the new 3rd party alut  
has different function signatures so you will get symbol clashes. But  
if you don't care about cross-platform compatibility or using 3rd  
party alut, then this is a quick simple hack.

So I think I have an example doing this hack to get the LoadWAV  
function.
http://playcontrol.net/ewing/jibberjabber/waveinterference_opengl_sha.html
(Find the DMG link and download it. The source code is inside.)

Apple also has a Mac specific OpenAL example found on your hard disk at:
/Developer/Examples/CoreAudio/Services/OpenALExample/
(assuming default Xcode install)

The Apple example will show you the Core Audio file loaders I think.

- Eric


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20090313/14ae9c07/attachment-0001.html


More information about the Openal mailing list