I have this code:
Synthesizer synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
Instrument[] instrument = synthesizer.getDefaultSoundbank().getInstruments();
synthesizer.loadInstrument(instrument[29]);
MidiChannel[] channels = synthesizer.getChannels();
MidiChannel channel = channels[1];
channel.programChange(29);
channel.noteOn(noteNumber, 127);
Teszthang.sleep(2000);
channel.noteOff(noteNumber);
so this is an example to play the sound in maximum volume (127) for 2 seconds. but I want to control the volume of the channel, as after 2 seconds, the volume disappears after another 2 seconds. How could I do this? I know these methods:
channel.controlChange(controller, value);
channel.setPolyPressure(noteNumber, pressure);
but they do not change any volume! I do not know how to use these methods. How can I change the channel volume after noteOn()during playback?
source
share