[SOLVED] OpenAL sound problems. (Also using Slick Util and LWJGL)

I have looked up a thousand and one different different ways to reproduce sound in LWJGL. None of them seem to work. It almost seems futile. All of them seemed to give errors, and those which didn’t, threw a NullPointerException to my WAV sound.

I have decided to stick with this tutorial by the Ninja Cave - http://www.lwjgl.org/wiki/index.php?title=Slick-Util_Library_-Part_2-_Loading_Sounds_for_LWJGL

Issue is, I’ve tried it on my game, and it seemed to fail. So, I copied the entire tutorial on a seperate class, changed the sound names to fit with the sound I had (I only used the WAV format and omitted the rest), and ran the program.

It game me this message:


Mon Jul 29 01:31:50 EEST 2013 INFO:Initialising sounds..
Mon Jul 29 01:31:50 EEST 2013 INFO:- Sound works
Mon Jul 29 01:31:50 EEST 2013 INFO:- 64 OpenAL source available
Mon Jul 29 01:31:50 EEST 2013 INFO:- Sounds source generated
java.lang.NoSuchMethodError: org.lwjgl.LWJGLUtil.log(Ljava/lang/String;)V
	at org.newdawn.slick.openal.WaveData.create(WaveData.java:126)
	at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:713)
	at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:683)
	at org.newdawn.slick.openal.AudioLoader.getAudio(AudioLoader.java:54)
	at spacegameII.SpaceGameII.main(SpaceGameII.java:83)

Any help would be greatly appreciated.

I’m just pegging a position so as to get updates. I am in the process of converting my game to libgdx and this will include my sound library, so I am very curious what the issues turn out to be. It will probably be a week or so before I know if my sounds work in the context of libgdx.

Looks like a simple JAR mismatch; SlickUtil is expecting an older version of LWJGL.

I would’ve liked to reply sooner, but I wasn’t notified about this page, how are the .jars mismatched if they came from the exact same zip file? I’ve also tried overwriting the lwjgl .jars too, along with their natives(with versions 2.90, 2.85, and 2.81), and they don’t seem to work…

Quick check: are you using Eclipse? Have you linked the libraries? I am putting the needed jars in “Referenced Libraries”, as part of the build path. (I ask because the error message says there is trouble locating the needed classes.)

I am going to try the tutorial you linked now. I just ran the “LWJGL Basics” for the first time earlier this week–haven’t tried the “Slick” tutorials yet.

OK, I got the tutorial to work. It is playing something…gack! I’m not sure each sound is exactly as it should be. There is no visual interface to speak of, just a blank screen. Ah-hah! You are supposed to play QWERT keys to get the various sounds. Yep. They all work. :o

Steps I took (there is probably a simpler way):

  1. Download the complete Slick.zip. From within (slick/testdata/…) I copied the audio data files listed in the SoundExample program into a folder in the Eclipse project which I also named “testdata”.

I had set up my project with a package named “lwjglTutorials” and put the tutorial class source file there. Setting the required testdata folder at src/lwgjlTutorials/testdata did NOT work. However, the program was able to find the resources when I changed the location to “src/testdata”. (Have to look at the API for ResourceLoader() to find out exactly what is expected here.)

  1. I linked as an “external jar” the following jars, all which can be found in either the Slick/lib or slick-util/lib folder:
    jogg-0.0.7.jar
    jorbis-0.0.15.jar
    ibxm.jar

Earlier I had linked lwjgl.jar and slick-util.jar.

That’s a lot to do–perhaps there was a simpler way to set this up without requiring all the additional steps.

Hope that gets you rolling. If not, I’m happy to try and help further.

I am using Eclipse, I made SURE to add them to the referenced libraries, otherwise the rest of my game wouldn’t work, and I even went as far as adding a few of the slick util libraries as well. Sound did not work.

I was using a wav file, and each time it would say:

Thu Aug 15 14:25:32 EEST 2013 INFO:Use Java PNG Loader = true
Thu Aug 15 14:25:32 EEST 2013 INFO:Initialising sounds..
Thu Aug 15 14:25:32 EEST 2013 INFO:- Sound works
Thu Aug 15 14:25:32 EEST 2013 INFO:- 64 OpenAL source available
Thu Aug 15 14:25:32 EEST 2013 INFO:- Sounds source generated
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream
Thu Aug 15 14:25:32 EEST 2013 ERROR:null
java.lang.NullPointerException
	at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:715)
	at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:683)
	at org.newdawn.slick.openal.AudioLoader.getAudio(AudioLoader.java:54)
	at spacegameII.SpaceGameII.playSound(SpaceGameII.java:127)
	at spacegameII.SpaceGameII.main(SpaceGameII.java:103)
	at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
	at org.newdawn.slick.openal.WaveData.create(WaveData.java:123)
	at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:713)
	at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:683)
	at org.newdawn.slick.openal.AudioLoader.getAudio(AudioLoader.java:54)
	at spacegameII.SpaceGameII.playSound(SpaceGameII.java:127)
	at spacegameII.SpaceGameII.main(SpaceGameII.java:103)
java.io.IOException: Failed to load: java.io.BufferedInputStream@13dd7d1
	at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:721)
	at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:683)
	at org.newdawn.slick.openal.AudioLoader.getAudio(AudioLoader.java:54)
	at spacegameII.SpaceGameII.playSound(SpaceGameII.java:127)
	at spacegameII.SpaceGameII.main(SpaceGameII.java:103)
Caused by: java.lang.NullPointerException
	at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:715)
	... 4 more

But then I saw a .wav file inside the slick.zip (not slick-util.zip), and tried it out, and it did in fact work. It turns out my .wav files were transferred from MP3 files before. So that likely messed up the bytecode. Thank you very much for solving my issue.

Glad to hear you got it to work!

One other thought (maybe you already know this):

Check if the .wav that didn’t play is 16-bit, 24-bit or 32-bit encoding. Java will usually balk unless the wav file is 16-bit. Converting from one to another can be done with Audacity (free DAW).

I’ll take that in note when I make my own sounds for my game :smiley: