我想使用java.I来控制OSX上的麦克风声级。我在源代码下使用但不支持Mac OS。有没有办法用OS控制OSX上的麦克风音量?
public static void setDeviceSensitivity(final int sensitivity) {
final Port lineIn;
// Mixer.Info[] mixerInfoPool=AudioSystem.getMixerInfo();
final Mixer mixer = AudioSystem.getMixer(null);
try {
if (mixer.isLineSupported(Port.Info.LINE_IN)) {
lineIn = (Port) mixer.getLine(Port.Info.LINE_IN);
lineIn.open();
} else if (mixer.isLineSupported(Port.Info.MICROPHONE)) {
lineIn = (Port) mixer.getLine(Port.Info.MICROPHONE);
lineIn.open();
} else if (mixer.isLineSupported(Port.Info.HEADPHONE)) {
lineIn = (Port) mixer.getLine(Port.Info.HEADPHONE);
lineIn.open();
} else {
System.out.println("Unable to get Input Port");
return;
}
lineIn.getControls();
if (lineIn.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
System.out.println("kewl");
}
final CompoundControl cc = (CompoundControl) lineIn.getControls()[0];
final Control[] controls = cc.getMemberControls();
for (final Control c : controls) {
if (c instanceof FloatControl) {
System.out.println("BEFORE LINE_IN VOL = "
+ ((FloatControl) c).getValue());
((FloatControl) c).setValue((float) sensitivity / 100);
System.out.println("AFTER LINE_IN VOL = "
+ ((FloatControl) c).getValue());
}
}
} catch (final Exception e) {
System.out.println(e);
}
}
答案 0 :(得分:0)
拿到麦克风:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />