Sound in OpenGL

Hi all,

I basically need to load a sound into a project, just like a background sound, nothing too fancy, but dont know where to start. My project contains a room build around 5 simple quads, and i basically want to add a sound, like the sound of being inside of a spaceship (in space).
I googled for a tutorial but couldnt find anything, only the OpenAL thing, which looks really complicated. Isnt there any easy code for copy/pasting for loading a sound file… just like simple html hehe :wink:

no there isn’t. any sound has nothing to do with a graphics API. stick to OpenAL. topic is totally opengl unrelated.

Look at this OpenAL tutorial at DevMaster web site.This should help you.

SDL has OpenGL and audio support.

Cool thank you very much!

So i have a small problem, because i am developing in Xcode on my Mac. The only 2 files included in the OpenAL framework are the following:
#include <OpenAL/al.h>
#include <OpenAL/alc.h>

where they state in the tutorial the following:
#include <conio.h>
#include <stdlib.h>
#include <al/al.h>
#include <al/alc.h>
#include <al/alu.h>
#include <al/alut.h>

they are using for instance the alutLoadWAVFile() function which i dont have the prototype for, because i dont have the alut.h library… any suggestions to what i can do?

suggestion : learn to use a search engine :slight_smile:
http://developer.apple.com/qa/qa2006/qa1504.html

Good idea. Thank you very much :slight_smile:

Ok well… .since i am a complete n00b at OpenGL/OpenAL, i get this awful messeage:

what does it mean?

oh, and there are absolutely no errors at line 110 in the alut.h file as my compiler indicates.
i just have this line of code:

ALUT_API ALUT_ATTRIBUTE_DEPRECATED void ALUT_APIENTRY alutLoadWAVFile (ALbyte *fileName, ALenum *format, void **data, ALsizei *size, ALsizei *frequency);

ALUT_ATTRIBUTE_DEPRECATED : and you wonder why you have a deprecation warning ?

Normally ‘deprecated’ means you should not rely on it in a future version. But it will work now.

According to the link I posted above, it would be better to use freealut instead of alut.

http://en.wikipedia.org/wiki/Deprecated

So better not use those functions and write your own. I think that goes for all alut functions. Better load the wav into a buffer and feed that to openal instead.

But opengl can be used for audioprocessing also. I believe in the ati sdk is an example on that.

I have never used OpenAL, but generally, ‘deprecated’ means that the function you are using should not be used. You should instead do it in the recommended way told by the OpenAL specification.
This function is still available to support old programs that already use OpenAL.

fmod is also available for free providing your are not making a commercial product. http://www.fmod.org/

I don’t know how it compared to OpenAL as I have never used OpenAL. However I found Fmod very quick and easy to set-up in my project.