Instrument change exported to midi

• Feb 7, 2021 - 10:55

Musescore doesn't place Program_c events in the middle of the midi file.

I have a one stave test score, which starts with a voice sound. After a few bars I change the instrument to a flute.
When I export it to a midi file, the midi file contains two channels. The instrument of each channel seems to be set in the beginning of the exported file, with time code 0. Then come the Note_on events. First we have the first channel Note_on events. After a few bars they end, then come the Note_on events of the second channel.
So the exported midi doesn't actually contain the exact moment of the instrument change. Am I right?

My issue with this is that I'd need the Program_c event to occur at the very same point where I place it in the score. I'm working on automating an old pump organ and I'd love to write all music using Musescore. A program change would mean pulling one organ stop and maybe pushing another. Therefore I'd need the midi events to happen where I place them in the score and not in the beginning. Can I use any other note that actually causes a midi event at the corresponding moment in the exported midi file?


I haven't studied this code in detail, but my sense is you are likely correct, I know there is that whole "MIDI action" section of the staff text properties dialog, also in articulation properties. I don't know that these actually do anything, but if you can convince them to send some sort of message, maybe that's good enough. Especially if you can also interpose a filter that looks for these messages and converts them to program changes.

In reply to by Marc Sabatella

The MIDI action does exactly the same. It creates a new midi channel for each change within the instrument. One channel for violin arco, one for pizzicato and one for tremolo. And these instruments are defined in the beginning with time code 0. So no real program change happens in the middle of the midi file. The Note_on events just have different channels depending on has there been a staff text that changed something.
So instead of looking for an absolute program change in the midi stream, I just pay attention in a change of channel in the Note_on stream. I just have to read the channel definitions in the beginning. I won't have an absolute number for say pizzicato, which would be the same from score to score. The first used sound or program is on channel 0, the next is on channel 1 and so on.

Do you still have an unanswered question? Please log in first to post your question.