Esempio n. 1
0
#    print(str(chord))

# render a melody
melody = composer.createMelody(progression)


# store music in a Song
song = Song()
chordTrack = Track(75)
pos = 0
for chord in progression:
    for note in chord.notes:
        chordTrack.addNote(pos, note)
    pos += 4
chordTrack.setVelocity(0x50)
song.addTrack(chordTrack)

melodyTrack = Track(57)
for pos, note in melody.items():
    melodyTrack.addNote(pos, note)
melodyTrack.setVelocity(0x70)
song.addTrack(melodyTrack)

# write the song to midi
out_file = 'out.mid'
song.writeToMidi(out_file)


os.system('timidity %s' % out_file)