The AudioSystem cant find the wav file tho the path is correct!


I got some problems with making sounds…

I found no tutorial but someone had posted here a great peice of code that I followed.

I tried, using AudioSystem to add a "checkpoint" sound…

Now it doesnt work…

It give me null exception, even tho I can copy the path and play the file from it!

It it the method or something that is null?  :?

Heres the code:

   private void setupSound() {
      String path = "C:\Users\Andreas\Desktop\RaceGame\";
      AudioTrack audBgMusic = AudioSystem.getSystem().createAudioTrack(path +"audio\Checkpoint.wav", false);

Very simple indead :D

Try with a URL:

URL url;
try {
    url = new URL("file:///C:\Users\Andreas\Desktop\RaceGame\audio\Checkpoint.wav");
} catch(Exception ex) {
    throw new RuntimeException("some kind of useful debug message");
AudioTrack audBgMusic = AudioSystem.getSystem().createAudioTrack(url, false);

Tyvm now it work :smiley:

And for others reading, incase you can still not hear your sound, then set the crossfadein time to 0

or else you might not hear the sound effect :slight_smile:

That happend to me anyways XD