Invalid format unter Linux

dsNDesign

Erfahrenes Mitglied
Hei,
ich kämpfe gerade ein bisschen mit meinem Programm unter Linux. Unter Windows läuft alles 1a, unter Linux will es jedoch noch nicht so ganz.

Ich fang mal hiermit an, denn darauf baut der Fehler glaube ich auf:

Ich habe eine Klasse Sound, wo eine Sounddatei abgespielt werden soll:
Code:
public Sound() {
		try {
			clip = AudioSystem.getClip();
			AudioInputStream inputStream = AudioSystem.getAudioInputStream(this.getClass().getResource("Sounds/sound.WAV"));
			clip.open(inputStream);
			clip.start();
			clip.loop(Clip.LOOP_CONTINUOUSLY);
			
//			gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
			
//			maxVol = gainControl.getMaximum();
//			minVol = gainControl.getMinimum();
			} catch (Exception e) {
				System.err.println(e.getMessage());
			}
	}

Das Programm läuft zwar, jedoch ohne Sound. Außerdem wird ein "Invalid format" ausgegeben.

Jemand ne Idee, woran das liegen könnte?

Gruß

EDIT:
Ok, die Musik läuft jetzt. Er kommt allerdings nicht mit der FloatControl klar.
Code:
public Sound() {
		try {
			clip = AudioSystem.getClip();
			AudioInputStream inputStream = AudioSystem.getAudioInputStream(this.getClass().getResource("Sounds/sound.WAV"));
			
			AudioFormat format = inputStream.getFormat();
			DataLine.Info info = new DataLine.Info(Clip.class, format);
			clip = (Clip)AudioSystem.getLine(info);
			
			clip.open(inputStream);
			clip.loop(Clip.LOOP_CONTINUOUSLY);
			
			gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
			
			maxVol = gainControl.getMaximum();
			minVol = gainControl.getMinimum();
			} catch (Exception e) {
				System.err.println(e.getMessage());
			}
	}

Code:
Master Gain not supported
 
Zuletzt bearbeitet:
Die Java Sound API ist offenbar etwas buggy, ich kann z.B. bei mir nicht feststellen, welche Bitraten einer meiner Eingänge besitzt. Aus der Dokumentation von clip.getControl():
Code:
Obtains a control of the specified type, if there is any. Some controls may only be available when the line is open.
[…]
Throws:
IllegalArgumentException - if a control of the specified type is not supported
Meine eigene Erfahrung: Du musst, wenn das in der Dokumentation erwähnt wird, davon ausgehen, dass die Methode Quatsch zurückgibt oder Exceptions wirft.
 
Zurück