Audio doesnt work after exporting game [SOLVED]

Hi,



when i run my game in eclipse, everything is fine.

But when i export it as a runnable jar, i am getting openAL exceptions, the background music doesnt play at all and soundeffects sound strange as well.



I use "java -jar -Djava.library.path=.libnatives connections.jar" to start the executable jar.



This is the exception i get when running the game:


08.10.2009 12:09:27 com.jmex.audio.openal.OpenALStreamedAudioPlayer playInNewThr
ead
SCHWERWIEGEND: Audio Error!
org.lwjgl.openal.OpenALException: OpenAL error: Invalid Value (40963)
        at org.lwjgl.openal.Util.checkALError(Util.java:64)
        at org.lwjgl.openal.AL10.alBufferData(AL10.java:1059)
        at com.jmex.audio.openal.OpenALStreamedAudioPlayer.stream(OpenALStreamedAudioPlayer.java:319)
        at com.jmex.audio.openal.OpenALStreamedAudioPlayer.playStream(OpenALStreamedAudioPlayer.java:190)
        at com.jmex.audio.openal.OpenALStreamedAudioPlayer.playInNewThread(OpenALStreamedAudioPlayer.java:214)
        at com.jmex.audio.openal.OpenALStreamedAudioPlayer.play(OpenALStreamedAudioPlayer.java:166)
        at com.jmex.audio.AudioTrack.play(AudioTrack.java:117)
        at com.jmex.audio.MusicTrackQueue.play(MusicTrackQueue.java:157)
        at gamestates.MenuState.setupAudio(MenuState.java:778)
        at gamestates.MenuState.<init>(MenuState.java:124)
        at main.Connections.initGame(Connections.java:133)
        at com.jme.app.BaseGame.start(BaseGame.java:74)
        at main.Connections.main(Connections.java:179)



What botheres me most is that i don't even know what the error is about exactly :(


I hope someone can help me with this problem




[EDIT AFTER SOLVED]:
see reply #7 and #8

please post this line here:

at gamestates.MenuState.setupAudio(MenuState.java:778)

here it is:



private void setupAudio() {
      // grab a handle to the audio system
      audio = AudioSystem.getSystem();
      // set overall volume
      audio.setMasterGain((float) gameSettings.getVolume() / 100);  // getVolume returns [0 .. 100]

      // setup our ear tracker to track the camera's position and orientation.
      audio.getEar().trackOrientation(cam);
      audio.getEar().trackPosition(cam);
      
      // setup a music track and start playing it
      AudioTrack music1 = getMusic(MenuState.class.getResource("/data/sound/1.wav"));
      audio.getMusicQueue().setRepeatType(RepeatType.ALL);
      audio.getMusicQueue().setCrossfadeinTime(2.5f);
      audio.getMusicQueue().setCrossfadeoutTime(2.5f);
      audio.getMusicQueue().addTrack(music1);
      audio.getMusicQueue().play();  // <


Line 778
   }



private AudioTrack getMusic(URL resource) {
      // Create streaming, looping, non-relative music clip.
      AudioTrack sound = AudioSystem.getSystem().createAudioTrack(resource, true);
      sound.setType(TrackType.MUSIC);
      sound.setRelative(false);
      sound.setVolume(1.0f);
      sound.setLooping(true);
      return sound;
   }

Probably a classpath is missing so getResource doesn't find the wav-file.

and where would i add that classpath?







aside from that, if i dont stream the musictrack, but load it as a whole, i get an OutOfMemory exception, which seems to indicate that it does find the music file

Than you have to increase the heap-size of the virtual machine.

Add this to the VM-arguments: "-Xmx256m" to increase the maximum heap-size to 256 MB.

Hi again





It works now :slight_smile:

I had to set the java heap space to 512mb though. The actual .wav file is only about 73mb in size.

Isnt there a way to reduce the memory amount needed? mp3 doesnt work, right?



I still wonder why streaming doesn't work  :-o I've also tried it with another .wav file, which is only about 1.5mb in size, but i got the same openAL exception that i posted in the opening post.





Anyways, thanks a lot for your help XD

I recommend OGG for audio.

Use Audacity to convert them: http://audacity.sourceforge.net

It is also perfect when you want to tweak/edit your sounds.

Thanks for the tip!



after using .ogg, i could even stream the music and i got no more OpenAL exceptions :smiley:

and i dont have to expand the heap space anymore as well.