|
@@ -1,20 +1,37 @@
|
|
|
package me.hammerle.supersnuvi.util;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
+import javax.sound.sampled.AudioFileFormat;
|
|
|
import javax.sound.sampled.AudioFormat;
|
|
|
import javax.sound.sampled.AudioInputStream;
|
|
|
import javax.sound.sampled.AudioSystem;
|
|
|
import javax.sound.sampled.Clip;
|
|
|
import javax.sound.sampled.DataLine;
|
|
|
-import javax.sound.sampled.LineUnavailableException;
|
|
|
-import javax.sound.sampled.UnsupportedAudioFileException;
|
|
|
+import javax.sound.sampled.Line;
|
|
|
+import javax.sound.sampled.Mixer;
|
|
|
import me.hammerle.supersnuvi.gamelogic.StateRenderer;
|
|
|
|
|
|
public class SoundUtils
|
|
|
{
|
|
|
- private static final AudioFormat WAV = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100.0f, 24, 1, 3, 44100.0f, false);
|
|
|
- private static final DataLine.Info INFO = new DataLine.Info(Clip.class, WAV);
|
|
|
+ private static AudioFormat WAV;
|
|
|
+ private static DataLine.Info INFO;
|
|
|
+
|
|
|
+ static
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ WAV = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100f, 24, 1, 3, 44100.0f, false);
|
|
|
+ INFO = new DataLine.Info(Clip.class, WAV);
|
|
|
+ }
|
|
|
+ catch(Exception ex)
|
|
|
+ {
|
|
|
+ WAV = null;
|
|
|
+ INFO = null;
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public enum Sound
|
|
|
{
|
|
@@ -57,7 +74,7 @@ public class SoundUtils
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- catch(IOException | LineUnavailableException | UnsupportedAudioFileException ex)
|
|
|
+ catch(Exception ex)
|
|
|
{
|
|
|
System.err.println("error with 'sounds/" + path + ".wav'");
|
|
|
System.err.println(ex);
|