Example #1
0
def run():
    import database as db
    selection = db.select()
    print(">>> Extracting deviations")
    deviations = db.getDeviation1(selection)
    print(">>> Loading score")
    score = db.getScorePath1(selection)
    print(">>> Loading alignment")
    alignment = Alignment(score, deviations)
    alignment.store("alignments/a1")
    print(">>> Generating performance")
    performance = alignment.performance()
    performance.exportMidi('output/generated.mid')
    #for n in performance[0:20]:
    #  print n.info()


    #output = open('temp.txt', 'w')
    #for n in nlist:
    #  output.write(str(n) + '\n')
    #output.close()
    import sequencer as seq
    sequencer = seq.Sequencer()
    sequencer.play(performance)
score = Score(db.getScore1(mozart2).stripTies())
melody = score.melody()
mozartnotes = tools.parseScore(melody)
delta2 = structure.square(structure.absolute_deltalist(structure.pitch, mozartnotes))
sodelta2 = structure.normalize(structure.second_order_deltalist(delta2))

s1 = structure.second_order_deltarule(chopinnotes, sodelta1, 0.1)
s2 = structure.second_order_deltarule(mozartnotes, sodelta2, 0.1)

while True:
    choice = util.menu("Select", ['Schumann exp', 'Schumann score', 'Schumann noexp', 'chopin struct', 'lastig struct bach', 'struct moz'])
    if choice == 0:
        path = db.getPerformancePath1(schumann)
        os.system("audacious {0}".format(path))
    if choice == 1:
        os.system("viewmxml {0}".format(db.getScorePath1(schumann)))
    if choice == 2:
        path = db.getScoreMidiPath1(schumann)
        os.system("audacious {0}".format(path))
    if choice == 3:
        groups = structure.groupings(structure.list_to_tree(s1), 1)
        structured_notes = []
        loud = False
        for group in groups:
            if loud:
                loud = False
            else:
                loud = True
            for leaf in group:
                if loud:
                    leaf.onvelocity = 80