Python的MIDI开发包 MIDIUtil
jopen
13年前
<p>MIDIUtil 是一个 Python 包,用来生成 MIDI 音乐文件。</p> <p>示例代码:</p> <p></p> <pre class="brush:python; toolbar: true; auto-links: false;">#Import the library from midiutil.MidiFile import MIDIFile # Create the MIDIFile Object with 1 track MyMIDI = MIDIFile(1) # Tracks are numbered from zero. Times are measured in beats. track = 0 time = 0 # Add track name and tempo. MyMIDI.addTrackName(track,time,"Sample Track") MyMIDI.addTempo(track,time,120) # Add a note. addNote expects the following information: track = 0 channel = 0 pitch = 60 time = 0 duration = 1 volume = 100 # Now add the note. MyMIDI.addNote(track,channel,pitch,time,duration,volume) # And write it to disk. binfile = open("output.mid", 'wb') MyMIDI.writeFile(binfile) binfile.close()</pre> <p></p> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326380102687" target="_blank">http://www.open-open.com/lib/view/home/1326380102687</a></p>