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

随声附和 提交于 2019-12-10 11:42:30

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/13795959/making-midi-files-in-python-that-are-polyphonic-and-different-instruments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!