23 package com.realtime.crossfire.jxclient.sound;
26 import java.io.IOException;
27 import javax.sound.sampled.AudioFormat;
28 import javax.sound.sampled.AudioFormat.Encoding;
29 import javax.sound.sampled.AudioInputStream;
30 import javax.sound.sampled.AudioSystem;
31 import javax.sound.sampled.Clip;
32 import javax.sound.sampled.DataLine;
33 import javax.sound.sampled.Line;
34 import javax.sound.sampled.LineUnavailableException;
35 import javax.sound.sampled.UnsupportedAudioFileException;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
73 public void freeClip(@NotNull
final Line clip) {
91 final AudioFormat baseFormat = rawInputStream.getFormat();
92 final AudioFormat decodedFormat =
new AudioFormat(Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels()*2, baseFormat.getSampleRate(),
false);
93 try (AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(decodedFormat, rawInputStream)) {
94 clip = AudioSystem.getClip();
95 clip.open(audioInputStream);
97 }
catch (
final IllegalArgumentException|NegativeArraySizeException ex) {
98 final UnsupportedAudioFileException ex2 =
new UnsupportedAudioFileException(ex.getMessage());
107 }
catch (
final IOException|LineUnavailableException|UnsupportedAudioFileException ex) {