python编写的midi制作软件

python编写的midi制作软件

ID:8791687

大小:49.00 KB

页数:9页

时间:2018-04-07

python编写的midi制作软件_第1页
python编写的midi制作软件_第2页
python编写的midi制作软件_第3页
python编写的midi制作软件_第4页
python编写的midi制作软件_第5页
资源描述:

《python编写的midi制作软件》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、用Python编写的Mid音频制作软件源代码如下:#Midi.py:#ThisfilecanbeusedtosimplyturnMidiTxtfiletoMidfile.#Author:loupen#Date:2010-7-20#Ifyouwanttouseit,youmustwritetheMidiTxtfilebysomerules.#Readthedocumenttolearnmore.fromstructimport*#ThreeglobalvariablesTrackBegin=[]TrackEnd=[]ToneFore=1#writeth

2、eMidiHeaderdefMidiHeader(buffer):buffer.write(pack('ccccBBBB','M','T','h','d',0,0,0,6))defmsg(buffer,tracks,deltatime):ifdeltatime>0xff:buffer.write(pack('BBBBBB',0,1,0,tracks,deltatime>>8,deltatime&0xff))else:buffer.write(pack('BBBBBB',0,1,0,tracks,0,deltatime))returnbuffer.te

3、ll()-3#writetheheaderandtailoftracksdefTrackHeader(buffer,list):buffer.write(pack('cccc','M','T','r','k'))list.append(buffer.tell())buffer.write(pack('i',0))defTrackTail(buffer,list):buffer.write(pack('BBBB',0,0xff,0x2f,0))list.append(buffer.tell())#Setthepulse,instrumentandcon

4、trollerdefSetSpeed(buffer,time):time=60.0/int(time)time=int(time*(10**6))buffer.write(pack('BBBBBBB',0,0xff,0x51,3,time>>16,(time&0xff00)>>8,time&0xff))return1#Thewords,FenZiandFenMu,arefromChinese.~O~defSetPulse(buffer,FenZi,FenMu):QQ:750825502E-mail:loupen@yeah.netFenZi=int(F

5、enZi)FenMu=int(FenMu)ifFenMu==2:FenMu=1elifFenMu==4:FenMu=2elifFenMu==8:FenMu=3else:return0buffer.write(pack('BBBBBBBB',0,0xff,0x58,4,int(FenZi),int(FenMu),0x18,0x08))return1defSetTone(buffer):buffer.write(pack('BBBBBB',0,0xff,0x59,2,0,0))return1defSetNumOrder(buffer,time):buff

6、er.write(pack('BBBB',time>>24,(time&0xff0000)>>16,(time&0xff00)>>8,time&0xff))defSetTrackNum(buffer,ad,n):buffer.seek(ad)buffer.write(pack('B',n+1))defSetInstrument(buffer,trackNum,ITNum):trackNum=int(trackNum)trackNum+=0xc0buffer.write(pack('BBB',0,trackNum,ITNum))defSetContro

7、ller(buffer,trackNum,CtrNum):trackNum=int(trackNum)trackNum+=0xb0buffer.write(pack('BBBB',0,trackNum,11,CtrNum))buffer.write(pack('BBB',0,0xa,0x40))defSetVolume(buffer,trackNum,S):trackNum=int(trackNum)trackNum+=0xb0ifS=='H':buffer.write(pack('BBBB',0,trackNum,7,0x7f))buffer.wr

8、ite(pack('BBB',0,0xa,0x40))ifS=='L':buffer.write(pack(

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。