示例#1
0
        print(second_order_tree(test, l, 0.0, deltalist_function=relative_deltalist))
        print(second_order_tree(test, l, 0.0))
        sys.exit(0)

    import database as db
    import tools
    w = db.select()
    score = Score(db.getScore1(w))
    melodyscore = score.melody()
    #melodyscore.show()
    melody = tools.parseScore(melodyscore, list(range(1, 9)))
    trees = [second_order_tree(onset, melody, 0.5), second_order_tree(pitch, melody, 0.0, ), first_order_tree(onset, melody, 0.0), first_order_tree(pitch, melody)]

    for tree in trees:
        print("Tree")
        print(tools.recursive_print(tree))


    for i in range(5):
        for j in range(len(trees)):
            groups = groupings(list_to_tree(trees[j]), i)
            avg_group = 0
            for group in groups:
                avg_group += len(group)
            avg_group /= float(len(groups))
            print("Tree: {0} Level {1} group size {2}".format(j, i, avg_group))
        print('------------------')
        if len(groups)/float(len(melody)) == 1: break

    print("Choose tree")
    tree = int(input(''))
        m = 1
    for i in l:
        result.append(i/m)
    return result

def square(l):
    result = []
    for i in l:
        result.append(i*i)
    return result

if len(sys.argv) > 1:
    notes = sys.argv[1]
    deltas = [int(x) for x in sys.argv[2]]
    s3 = structure.second_order_deltarule(notes, deltas, 0)
    print(tools.recursive_print(s3))
    sys.exit(0)


selection = db.select()
score = Score(db.getScore1(selection).stripTies())
melody = score.melody()
notes = tools.parseScore(melody)
deltas = []


print("COMBINED DELTA TREES")
#for feature in [structure.pitch, structure.onset]:
#  deltas.append(normalize(structure.repetition(feature, notes)))

for feature in [structure.onset, structure.duration, structure.pitch]: