The audio sytem provides special port mixers with port lines.
You have to open this lines, get the controls and adjust them.
Here is a small program which prints the current values of the controls.
It may help you to learn how to access the controls.
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.BooleanControl;
import javax.sound.sampled.CompoundControl;
import javax.sound.sampled.Control;
import javax.sound.sampled.EnumControl;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Port;
public class MixerTest {
public MixerTest() throws LineUnavailableException {
Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
for (Mixer.Info mixerInfo:mixerInfos) {
Mixer m = AudioSystem.getMixer(mixerInfo);
Line.Info[] lineInfos = m.getSourceLineInfo();
for (Line.Info li:lineInfos) {
if (li instanceof Port.Info){
Port.Info pi=(Port.Info)li;
Line portLine=m.getLine(pi);
printPortControls(portLine);
}
}
lineInfos = m.getTargetLineInfo();
for (Line.Info li:lineInfos) {
if (li instanceof Port.Info){
if (li instanceof Port.Info){
Port.Info pi=(Port.Info)li;
Line portLine=m.getLine(pi);
printPortControls(portLine);
}
}
}
}
}
private void printPortControls(Line portLine) throws LineUnavailableException{
portLine.open();
Control[] pCtrls=portLine.getControls();
for(Control memberControl:pCtrls){
printControl(memberControl);
}
portLine.close();
}
public void printControl(Control memberControl) {
if (memberControl instanceof BooleanControl) {
BooleanControl bc = (BooleanControl) memberControl;
System.out.println(bc + ": " + bc.getValue());
} else if (memberControl instanceof FloatControl) {
FloatControl fc = (FloatControl) memberControl;
System.out.println(fc + ": " + fc.getValue());
} else if (memberControl instanceof EnumControl) {
EnumControl ec = (EnumControl) memberControl;
System.out.println(ec + ": " + ec.getValue());
} else if (memberControl instanceof CompoundControl) {
CompoundControl cc = (CompoundControl) memberControl;
System.out.println(cc);
for (Control compControl:cc.getMemberControls()) {
printControl(compControl);
}
}
}
/**
* @param args
*/
public static void main(String[] args) {
try {
new MixerTest();
} catch (LineUnavailableException e) {
e.printStackTrace();
}
}
}