Tuning tool channels using javax.sound.midi package

I am having problems setting up the tool in the javax.sound.midi package.

Synthesizer synthesizer = MidiSystem.getSynthesizer(); MidiChannel[] channels = synthesizer.getChannels(); channels[0].programChange(5); System.out.println(channels[0].getProgram()); 

From the documentation for MidiChannel, calls to the channels [0] .programChange (int) should change the tool on which MidiChannel is installed and is immediately displayed in the channels [0] .getProgram (). However, my program prints "0", indicating that nothing has changed.

Later in the code, I use MidiChannel.getSequencer () to successfully play MIDI sound (although only with the default tool).

Am I trying to install the tool incorrectly?

+4
source share
1 answer

I encountered the same problem as you, although we do not use the same implementation as MIDI messages, which can freely look at my question, as this may come in handy:

Changing a tool in Java during playback

+3
source

Source: https://habr.com/ru/post/1309688/


All Articles