Advertisement

OpenAL

Started by March 15, 2005 02:10 PM
9 comments, last by BangorRipper 19 years, 11 months ago
First of all is OpenAL supported by most modern day sound cards? And secondly are there any decent code snippets out there that make it easy to see how it is used for someone who has never ever dealt with sound in a game before thanks
Yes, it is supported on any sound card as long as you install the most recent drivers.

For tutorials take a look at this site. Those are pretty much the best there is right now. Also you will want to look at the sample included in the SDK. It goes over a lot of other stuff as well.

There are a few tutorials on GameDev as well, here and here.

- Drew
Advertisement
is it ok to just use free wav sounds off somewhere like 3dcafe.com or do you need to use special sound files to get good sound?
thanks
Good sound is based on the quality of the files used. So if the files that are free are of decent quality, then yes, that should be fine. However, if you are doing a professional game, you would want to use professional sounds [wink]. What type of project are you doing with OpenAL?
just a small personal one so i guess free stuff is fine then, i am trying to do it using java, lwjgl actually, cannot seem to get the following to compile which i think is just some introductary basic code:

import net.java.games.joal.*;
import net.java.games.joal.util.*;
import java.io.*;
import java.nio.ByteBuffer;

public class Sound {

static AL al = ALFactory.getAL();

// Buffers hold sound data.
static int[] buffer = new int[1];;

// Sources are points emitting sound.
static int[] source = new int[1];
}


i get:

--------------------Configuration: JDK version 1.5.0_01 <Default>--------------------
C:\Documents and Settings\Danny\Desktop\Version2.0.13\Version2.0.7\Version2.0.5\Version2.0.5\Sound.java:1: package net.java.games.joal does not exist
import net.java.games.joal.*;
^
C:\Documents and Settings\Danny\Desktop\Version2.0.13\Version2.0.7\Version2.0.5\Version2.0.5\Sound.java:2: package net.java.games.joal.util does not exist
import net.java.games.joal.util.*;
^
C:\Documents and Settings\Danny\Desktop\Version2.0.13\Version2.0.7\Version2.0.5\Version2.0.5\Sound.java:8: cannot find symbol
symbol : class AL
location: class Sound
static AL al = ALFactory.getAL();
^
C:\Documents and Settings\Danny\Desktop\Version2.0.13\Version2.0.7\Version2.0.5\Version2.0.5\Sound.java:8: cannot find symbol
symbol : variable ALFactory
location: class Sound
static AL al = ALFactory.getAL();
^
4 errors

Process completed.

any ideas, i'm sorry but i am a total newbie :(
Oh dear! I'm sorry but I cannot help you with that. Java is not my field of expertise [sad]. However, you might want to look around on these forums. Hopefully someone that knows OpenAL with Java can help.
Advertisement
Quote:
Original post by BangorRipper
First of all is OpenAL supported by most modern day sound cards?
And secondly are there any decent code snippets out there that make it easy to see how it is used for someone who has never ever dealt with sound in a game before
thanks


OpenAL utilizes DirectSound on Windows platforms, so I cannot imagine that it wouldn't.
There's lots of snippets, just search Google ;-)
Game or not, you only need to know how to use it, not specificly for a game, since that's the same only with a different structure and command path.
You should also get the OpenAL SDK:
http://developer.creative.com/landing.asp?cat=1&sbcat=31⊤=38
Killers don't end up in jailThey end up on a high-score!
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
have sorted it now thanks for all replies
Quote:
Original post by BangorRipper
have sorted it now thanks for all replies


Can you post what you had to do for future references? Or was it just a slipup?

This topic is closed to new replies.

Advertisement