OpenAL

Started by ug02070, March 15, 2005, 21:55:42

Previous topic - Next topic

ug02070

are there any code snippets or tutorials that can help me with OpenAL in lwjgl plz. I am very new to lwjgl but i just need to add three sounds, a background sound, a sound when my player shoots and a sound when a level is completed. I do not need anything technical but a good example or walkthrough would be gr8 if anyone knows of one.
thanks

ug02070

ok, i have used the code from the space invaders example that comes part of lwjgl, but when i am for instance trying to get the shot sound to play when i shoot, how can i do it so that it works correctly when the shoot button is held down..i have the following

      if(Keyboard.isKeyDown(Keyboard.KEY_SPACE)&&(!playerDead))
      {
         boolean firePressed = true;
         if(firePressed)
         {
            tryToFire();
         }
      }

   public void tryToFire()
   {
      createShipBullet();
      shipBullet.renderBullet();
      bulletCreated = true;
         soundManager.playEffect(SOUND_SHOT);
   }

is there something that needs including so that the sound is played correctly, if shoot is held down, its almost as though the sound is held until it is released and then the rest of the sound is played, thanks

tomb

Don't know about the space invaders stuff, but here is a good OpenAL tutorial:
http://www.devmaster.net/articles/openal-tutorials/lesson1.php

There is also more in depth docs on www.openal.org

ug02070

have sorted sounds now thanks for all replies

Matzon

if we're going to link to devmaster's tutorial, why not the LWJGLized one ? ;)
http://lwjgl.org/documentation_openal_01.php

ug02070

i use the sound from the class:
org.lwjgl.examples.Game
it is downloaded from lwjgl.com

it is sort of like so:
private static SoundManager   soundManager;

         soundManager = new SoundManager();
         soundManager.initialize(8);

     // load our sound data
         SOUND_SHOT   = soundManager.addSound("shot.wav");
         SOUND_HIT    = soundManager.addSound("hit.wav");
         SOUND_START  = soundManager.addSound("start.wav");
         SOUND_WIN    = soundManager.addSound("win.wav");
         SOUND_LOOSE  = soundManager.addSound("loose.wav");

and then call it like so:

soundManager.playSound(SOUND_START);

this works fine and sound is produced but is there anything else that i can do to these sounds to make more use of the api and to possibly improve the sound?
thanks

Matzon

eh? - what do you mean?
there is a ton of stuff you can do with the openal api - check out the openal documentation http://openal.org

ug02070

i mean that i have these VERY BASIC sounds and i was just wondering if there are a few mehtods that make them sound better without too much bother, just a simple effect that would improve what i already have
thanks

Matzon

Well, basically the best way to make sound, sound better, is to use some decent sound effects. You can rearely make the sounds better by applying effects.
But basically, OpenAL doesn't have anything to do with effects and what not, it just plays sounds - and applies whatever "effects" needed as defined by the 3d space the sound is in.

So the best way to make a Shot effect sound better, is to find or make another one :)

ug02070

ok cheers,
does anyone know of any sites that are good for space sounds etc that are good quality and will sound good with OpenAL
also do a lot of you use it as it seems so simple just to play a sound?

tomb

Quote from: "Matzon"if we're going to link to devmaster's tutorial, why not the LWJGLized one ? ;)
http://lwjgl.org/documentation_openal_01.php
Hehe, didn't know about that :oops:  I just remembered the tutorial way back when I did the OpenAL stuff, and googled for it. It's great that there is a lwjgl version. Makes me wonder what other goodies are on the lwjgl site  :D