LWJGL
February 07, 2012, 05:40:49 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Noob questions about OpenAL  (Read 1252 times)
lainmaster
Regular nerd
**
Posts: 64


« on: March 10, 2010, 20:58:11 »

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
Logged
princec
Nerdus Imperius
*****
Posts: 1751



WWW
« Reply #1 on: March 11, 2010, 04:21:41 »

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 Smiley
Logged

lainmaster
Regular nerd
**
Posts: 64


« Reply #2 on: March 11, 2010, 09:49:25 »

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?
Logged
princec
Nerdus Imperius
*****
Posts: 1751



WWW
« Reply #3 on: March 12, 2010, 01:55:02 »

Well, it sounds awful Smiley

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 Smiley
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!