Noob questions about OpenAL

Started by lainmaster, March 11, 2010, 04:58:11

Previous topic - Next topic

lainmaster

Hey there, I was just reading the tutorial (http://lwjgl.org/documentation_openal_01.php) for OpenAL and some questions came to mind.

Can it play background music? (I mean, sounds with no source/listener?)
Is it worth it for just background music?
Does it work on all platforms?

I'm currently using midis for my background music, and I think the best alternative to that is some sort of sampled system, since I can't afford over half a MiB per song. The sampled system would be ideal but for now midis will have to do. Come to think of it, I'm guessing there's no way OpenAL could play midis since they are commands for the sound card and OpenAL still isn't hardware accelerated, right?

Suppose I record the sounds of many instruments but not all the notes, and I want to make a sampled system, is there a way to change the pitch of a sound with OpenAL?

Thank you

princec

You always need a source and a listener. The source need not be positioned anywhere in particular, which is how you do background music. To do background music, you need to decode and stream OGG data into a ring sequence of OpenAL buffers, which you queue up on a source when each becomes full. This seems to work perfectly reliably on all platforms I've tested it on so far.

The only format OpenAL currently accepts is PCM (ie. wave data), which you can supply by the aforementioned OGG decoding. There's no MIDI for it unfortunately. You can change the pitch of buffers but only down - that is you can lower the pitch but not raise it.

Cas :)

lainmaster

Thanks, that's what I needed to know about oAL. I'm thinking I'll stick to javax.sound.midi for now, is there anything bad about it?

princec

Well, it sounds awful :)

I do believe that some clever people have written tracker playback libraries that stream PCM data to OpenAL. I'll leave the googling to you...!

Cas :)