I have used this template to write a program that writes MIDI files, the only problem I am having now is changing the instrument
This code segment is commented to set the instrument to piano, but I would like to know if there are other instruments I could set it to with different message inputs.
//**** set instrument to Piano ****
mm = new ShortMessage();
mm.setMessage(0xC0, 0x00, 0x00);
me = new MidiEvent(mm,(long)0);
t.add(me);
Other instruments are specified in the general MIDI standard, though not all synths are guaranteed to support these sounds.
Also, a MIDI program change message is only 2 bytes, not 3. Looking at the example template code you linked to , it seems that the
setMessage()method provides the appropriate overrides for this. If you write 3 bytes to this message, then the 3rd byte will be erroneously interpreted as the first byte of the next message.