midiutil with python doesnt write drumset sounds in channel 10?

Viewed 142

Im trying to write a complete music using midiutil library with python. So far, i have been able to add any instrument i've wanted via

MIDIFile.addProgramChange(track, channel, time, program)

and taking the program number from the table at https://www.midi.org/specifications-old/item/gm-level-1-sound-set

However, i cant add any drumset sounds the way i want. I know channel 10 is reserved for percussion, but whenever i write anything via

MyMIDI.addNote(track, 10, pitch, time + i, duration, volume)

the sound played by musescore is played in the piano voice or in the voice defined by the ProgramChange method. I know there is drumset sounds somewhere in my computer because i have been able to manually add drumset sounds in musescore. Am i doing something wrong?

1 Answers

Humans begin counting at one, so you have channels 1 … 16.
Computers begin couting at zero, so they have channels 0 … 15.

The addNote() documentation says that the channel parameter is an integer from 0 to 15, so you must use 9 for the percussion channel.

Related