微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

MIDIUtil Python的MIDI开发包

程序名称:MIDIUtil

授权协议: MIT

操作系统: 未知

开发语言: Python

MIDIUtil 介绍

MIDIUtil 是一个 Python 包,用来生成 MIDI 音乐文件

示例代码

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 @R_75_4045@ion:

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()

MIDIUtil 官网

http://code.google.com/p/midiutil/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐