Re: Java API sound
Thanks for reading my post.
So this is my code :
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
public class ControlTest {
public static void main(String[] args) throws
LineUnavailableException, InterruptedException {
Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
for (int i = 0; i < mixerInfos.length; i++) {
Mixer mixer = AudioSystem.getMixer(mixerInfos[i]);
Line.Info[] targetLineInfos = mixer.getTargetLineInfo();
for (int j = 0; j < targetLineInfos.length; j++) {
setVolume(targetLineInfos[j]);
}
}
}
static boolean setVolume(Line.Info lineInfo) {
try {
Line line = AudioSystem.getLine(lineInfo);
System.out.println(line.getLineInfo());
line.open();
FloatControl control =
(FloatControl)line.getControl(FloatControl.Type.VOLUME);
control.setValue(control.getMinimum());
line.close();
System.out.println("Volume : " + control.getValue());
} catch (Exception e) {
System.out.println(e);
return false;
}
return true;
}
}
I will modify sound for microphone and speaker. On my personal computer
it works. But i'm trying on another computer with different driver and
it modify only the speaker volume not microphone volume.
I've got this error :
interface TargetDataLine supporting 8 audio formats, and buffers of at
least 32 bytes
java.lang.IllegalArgumentException: Unsupported control type: Volume
interface TargetDataLine supporting 8 audio formats, and buffers of at
least 32 bytes
java.lang.IllegalArgumentException: Unsupported control type: Volume
SPEAKER target port
Volume : 0.0
Any ideas ?
Andrew Thompson a =E9crit :
boutreau.adr...@gmail.com wrote:
This is same error for Volume ..
What is? Please refrain from top-posting.
Andrew T.