如何Java Midi STOP

时间:2010-09-23 08:26:32

标签: java audio midi

如何阻止java应用程序发出任何声音?

1 个答案:

答案 0 :(得分:1)

查看Sound API

要简单地静音,您可以执行以下操作:

Port p = (Port)AudioSystem.getLine(Port.Info.SPEAKER);
p.open();

//print out volume
FloatControl vol = (FloatControl)p.getControl(FloatControl.Type.VOLUME);
System.out.println("Current Volume: " + vol.getValue());

//mute sound
BooleanControl mute = (BooleanControl)p.getControl(BooleanControl.Type.MUTE);
mute.setValue(true);

p.close();