def newMelody(length): melody = [] for index in newNoteIndexListM(length): k = random.random() note = Note(allNotesM[index]) if k < pOfChromatics: note.augment() elif k > 1 - pOfChromatics: note.diminish() melody.append(note) return melody
n = Note('C') #变为C5 n.set_note('C', 5) #音对象属性 n.name #十二音名 n.octave #第几八度 n.dynamics #其它属性 #音对象方法 int(n) #音对象的数值 c = Note() c.from_int(12) #使用数值创建音对象 c.octave_up() #升八度 c.octave_down() #降八度 c.change_octave(2) #升n八度 c.transpose('3', up=True) #向上升三度 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()