OpenAL implementation 0.02

Last Friday I did a CVS checkout of panda and added OpenAL support over the weekend. These are the most lines of C++ I have ever written, but it seems to compile and even run :slight_smile: .

What it does:

  • load .wav files
  • play 3d positioned sound
  • set volume, pitch (play rate) for each sound
  • set volume, pitch for all sounds that belong to an AudioManager at once.
  • load a sample into memory once, play it many times.
  • work on my pc (Fedora Core 6 Linux PC).

What it does not (yet):

  • load .ogg, .mp3, …
  • some small settings that are different between fmod and OpenAL, e.g. speed of sound, drop-of factor.
  • smarter loading/unloading of samples. Currently a sample is loaded when a sound requests it. Only when an AudioManager is deleted are all samples unloaded. Would this be okay or are there better scenarios?
  • work on any other computer? :wink:

If you are interested, these are (hopefully all) the files I made/modified (updated to version 0.02, see below):

whowhowhow =) those are good news!
really cool to see how fmod is beeing replaced. really cool. keep up the work!
and a biiiig thx for contributing to panda3d 8)

Innnteresting. I just saw this post. Are you still working on this, Laurens?

Over the summer, I was planning on adding an OpenAL audio manager with FFMpeg as the library for loading files. This would give us a lot of formats, plus the ability to play movies with sound as well.

It looks like you’ve done half my work for me. Are you still working on this?

I planned to work a bit more on this, but had no time yet. Most OpenAL stuff is implemented. I was thinking about how to load any other file format than plain .wav. I had not considered ffmpeg, but it is the most logical choice here.

I plan to add the last OpenAL related stuff (changing some settings, such as speed of sound) soon. If you have experience with ffmpeg, it would be nice if you could add support for loading different formats.

I do have experience with ffmpeg. I can implement this. Thank you very much for giving me an OpenAL framework to begin with! This is going to make it much easier.

I added some things:

  • setting speed of sound, doppler factor, drop off factor
  • looping a finite number of times (does anyone use this?)
  • calculation of Doppler shift.

The latter is done, because there is a problem with the SI OpenAL implementation on Linux. Actually, the problem seems to be that there is no active maintainer and all kinds of bugs don’t get solved, such as Doppler shifting not working. You can switch between OpenAL’s Doppler shifting and my own by defining DOPPLER_HACK in alAudioSound.h .

What remains is:

  • more testing.
  • using ffmpeg to load many file formats.
  • maybe some smarter way of (un)caching sounds.

I have updated the tar ball that’s linked to in the first post.

Josh: I am hoping you will pick up from here to do the ffmpeg work.

i have got my own python ctypes wrapper of openAL but having it in C++ would be faster! I was working on getting ogg verbs lib to load ogg files but have not gone to far besides the basic openAL wrap.

Did you find some OpenAL things not to work such as Doppler shift and set/get time?

well i am a sound n00b and have not used the features. I think the manual Doppler shift does not work but the automatic one where you set the listener, set the positions and set the velocity does. Timing also appears not to work but i am not timing any thing with sound. They complete when thy should after being played. But yes treating the features as they are not there is not a good solution :slight_smile: But even without these it still a free sound system.