Пример #1
0
def main(args):
    if (len(args) == 0):
        print("Input followed by a list of chords seperated by spaces")
    else:
        b = ""
        for i in range(0, len(_flats)):
            newChords = transposeChords(args, i)
            a = " ".join(newChords)
            b += " " + a[0]
            print(a[0])
        print("This is " + b)
        nc = NoteContainer([b])
        MidiFileOut.write_NoteContainer("test.mid", nc)
Пример #2
0
c.augment()  #升半音
c.diminish()  #降半音
c.remove_redundant_accidentals()  #清理多余升降号(只能成对清理,烂)

#谱容器
from mingus.containers import NoteContainer
#创建谱容器对象(继承列表,完全可以按列表操作,不用看下面的)
n = NoteContainer(['A-3', 'C-5', 'B-4'])
n.add_note('F-1')  # 0位加音
n.remove_note('B', 4)  #删音
n.empty()  #清空

#乐器音色
from mingus.containers.instrument import Instrument, Piano, Guitar
#创建乐器对象
i = Instrument()
i.range  #乐器音域
i.set_range((Note('C-2'), Note('E-4')))  #设定音域
i.note_in_range('F-4')  #判断音是否在乐器音域内
#音轨
from mingus.containers import Track
t = Track(i)  #乐器放入音轨容器

#MIDI音乐播放(安装困难)
#from mingus.midi import fluidsynth
#fluidsynth.init("soundfont.SF2")
#fluidsynth.play_Note( Note('C-5') )

from mingus.midi import MidiFileOut
MidiFileOut.write_NoteContainer('test.mid', n)