Only PCM convert for BigClip.
This also eliminates the creation of the audio line when we're using BigClip
because BigClip blindly recreates the audio-line internally regardless of
whether we pass one in or not.
@@ -47,8 +47,12 @@ public class JavaAudio extends Audio {
try {
AudioInputStream ais = rsrc.openAudioStream();
AudioFormat format = ais.getFormat();
+ Clip clip;
+ if (music) {
+ // BigClip needs sounds in PCM_SIGNED format; it attempts to do this conversion
+ // internally, but the way it does it fails in some circumstances, so we do it out here
if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
- format = new AudioFormat(
+ ais = AudioSystem.getAudioInputStream(new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
format.getSampleRate(),
16, // we have to force sample size to 16
@@ -56,14 +60,12 @@ public class JavaAudio extends Audio {
format.getChannels()*2,
format.getSampleRate(),
false // big endian
- );
- ais = AudioSystem.getAudioInputStream(format, ais);
+ ), ais);
}
-
+ clip = new BigClip();
+ } else {
DataLine.Info info = new DataLine.Info(Clip.class, format);
- Clip clip = (Clip) AudioSystem.getLine(info);
- if (music) {
- clip = new BigClip(clip);
+ clip = (Clip) AudioSystem.getLine(info);
}
clip.open(ais);
sound.succeed(clip);
