Sign in to follow this  
Ludi83

A few OpenAL questions

Recommended Posts

Ludi83    300
Hi! I want to use OpenAL for music playback in my game, so I am currently writing a music manager. I have written my class-definition today, and now I want to implement my ideas. But before starting, I have some questions: 1. How can I retrieve the length of a wave file? 2. Is it possible to stream a wavefile, without loading it completly into memory? 3. Is there a 2D Mode, so that I don't have to change the music source position to the current play position? And if it's possible, how can I change the volume of the music? Greetings Marko

Share this post


Link to post
Share on other sites
rjhcomputers    130
1) Should be in the header of the wave file.
2) You would have to write your own wave handler, but yes. As long as you keep the buffers full with data there should be no problem.
3) If you set the sound source relative to the listner, you do NOT have to update the position of the sound. To change it's volume, just change the gain of the source.

Ill admit I'm no expert, but this is correct to the best of my knowledge. For music playback, why not try OggVorbis? There are a few tutorials on how to stream it and it would save space.

Share this post


Link to post
Share on other sites
Drew_Benton    1861
Quote:
Original post by rjhcomputers
Ill admit I'm no expert, but this is correct to the best of my knowledge. For music playback, why not try OggVorbis? There are a few tutorials on how to stream it and it would save space.


You seem all correct to me [smile]. Ludi83 what you want to do is look in the OpenAL SDL folder. In the "\Samples\Source\OpenALDemo" folder there is a project that you can open and take a look at. It shows all of the basic features. Note that you will need to comment out all of the EAX stuff so it can compile. It already has a streaming wav example done as well.

For more tutorials take a look at this site. It was very help for me. I have recently finished an OpenAL audio library for our game. I used DevMaster as well as the SDK example. Also please read the documentations! You will save yourself a lot of troubles - such as only mono files can have positions.

As for a little extension on #3, the way OpenAL works is by defauly, all sounds are positioned at 0,0,0 and the listener is initialized at that location. So if you do not change the listener position, then all your sounds are basically 2D sounds. In the SDK example it shows how to change volume as well (AL_GAIN).

Good luck!

Share this post


Link to post
Share on other sites
rjhcomputers    130
And a side note to save headaches latter on, avoid the ALUT libs. They have been depricated. Also note that Garin and his team are changing ALOT of things in the 1.1 implementation of the dll. They should NOT break 1.0 apps but no garuntees[sp?].

Share this post


Link to post
Share on other sites
Ludi83    300
Thank for your answers, guys. After reading through the examples of the SDK and on Devmaster, it was really easy to complete my music manager with fading, streaming and so on..

But I have one more question about wave/ogg:

What format should I use? After thinking about the formats, I got the following conclusion:
Wave: (e.g. KotOR2 or Quake uses Wave files)
+ Less CPU time, because the file is put into the buffer 1:1
- More Harddisk I/O
- More Diskspace needed

Ogg: (e.g. FarCry)
+ Less Diskspace
+ Less I/O
- Higher CPU time, because of the decoding of the file

Are there more Pros and Cons? What music formats are you using?

Share this post


Link to post
Share on other sites
Drew_Benton    1861
If you have quick very small sound effects, there would be no problem using .WAV/.OGG in that case. However, if you are going to have level music or title screen music, etc... you will definitly want to use .OGG. A 3 minute soing can be compressed into a few MB with OGG, but be nearly a hundred in the .WAV format.

I say the cost of the extra decoding is well worth using .OGG. You can stream them from your HDD so memory is saved as well. Now adays though, what is CPU time? Computers are getting faster and faster. Having a little overhead because you are using OGG compared to WAV is definitly worth the tradeoff.

We are using .OGG for our game, both small and large sounds. It's just more convient this way to save the max amount of space. I would say if possible, just use all OGG. If you have a decent game graphics capabilities wise, then it will be well worth it [wink].

- Drew

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this