openAL WAV loading

Started by
6 comments, last by yahn 17 years, 2 months ago
Can anyone tell me how to load a WAV file without using alutLoadWAVFile? I'm asking because ALut is saying that alutLoadWAVFile is depreciated. Also, when I use it I get warnings and I can't get the sound to play back either. Every time I search for "openAL WAV" I get a result using alutLoadWAVFile. So, can anyone help me out?
Advertisement
Hi

I didn't know it was depricated, where did you get that info from ? I have no idea actually what to use instead. I can only recommend using ogg vorbis, but then you have do the streaming, which is fairly hard to get right.
Pretty easy. Open up the wave file, read the riff information, deocde it to a buffer, and give that buffer to OpenAL. If you want, you can take a look at my wave loading code in my wip game engine:
https://www.wreckedgames.com/svn/wge/trunk/src/Codecs/WavCodec.cpp

You can download the whole source by going to:
https://www.wreckedgames.com/svn/wge/trunk/

Feel free to use the wave loading stuff, even though my code is GPL, I don't have a problem with you borrowing something so trivial. The code there uses an abstraction layer to pass the decoded audio to any sound library (namely OpenAL & Fmod in my code). You can look at the OpenAL plugin in my code base to see how the sound is put to a OpenAL source.

Hope that helps. Note: I used the raw wave loader since I didn't want to use Alut (just like you). It handles basic wave files using either 16 or 8 bit audio / mono/multi channel audio.

Edit - clickified links!
Is there a reason why I can't play the sound after I call glutMainLoop()? It works before I call that, but after I call glutMainLoop() I hear nothing.
Avoid Glut, it's not really maintained anymore. Just learn and use an OS and OpenGL.
Quote:Original post by Anonymous Poster
Avoid Glut, it's not really maintained anymore. Just learn and use an OS and OpenGL.


Alternatives include GLFW, Allegro, SDL and ClanLib.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!
RTFM:
http://www.openal.org/openal_webstf/specs/alut.html#alutCreateBufferFromFile
RAZORUNREAL thanks for the suggestions, but I really don't want to completely change my project. GLFW may work, but unless I know what the problem is, I don't know how I'm going to fix it. Can anyone tell me why a sound can't be played once glutMainLoop() is entered? And how could GLFW change that? I know there have been games that use glut and alut that play sounds. So, there must be a way to work around this.

This topic is closed to new replies.

Advertisement