import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Sequencer;
import javax.sound.midi.Synthesizer;
public class Main {
public static void main(String[] argv) throws Exception {
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
if (sequencer instanceof Synthesizer) {
Synthesizer synthesizer = (Synthesizer) sequencer;
MidiChannel[] channels = synthesizer.getChannels();
// gain is a value between 0 and 1 (loudest)
double gain = 0.9D;
for (int i = 0; i < channels.length; i++) {
channels[i].controlChange(7, (int) (gain * 127.0));
}
}
}
}