Making Midi Files in Python that are Polyphonic and Different Instruments [closed]

StackOverflow https://stackoverflow.com/questions/13795959

  •  06-12-2021
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top