Domanda

I'm looking for a midi library in Python that will allow me to create a polyphonic midi file using different instruments.

What seems to get recommended here alot is MidiUtil. Although, it seems to have support for polyphony, I can't seem to change the instrument from piano.

Can anyone recommend an alternative midi library or advise on how to change the instrument?

È stato utile?

Soluzione

To do this, each of the different timbres that you'd like to use in your file need to have their events on a separate MIDI channel. Before any notes sound on each channel, use the addProgramChange()method of the MIDIFIle object to select the correct patch on each channel.

addProgramChange(track, channel, time, program)

Add a MIDI program change event.

Use MyMIDI.addProgramChange(track,channel, time, program)

Arguments

track: The track to which the event is added. [Integer, 0-127].
channel: The channel the event is assigned to. [Integer, 0-15].
time: The time at which the event is added, in beats. [Float].
program: the program number. [Integer, 0-127].

See http://www.emergentmusics.org/mididutil-class-reference for documentation of all the methods supported by that class.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top