-
Notifications
You must be signed in to change notification settings - Fork 0
/
animalplay.py
executable file
·106 lines (83 loc) · 2.94 KB
/
animalplay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
import redis
from database import Database
from notate import notate_score, notate_parts, notate_Bb_clarinet_part
from score import make_score
from form import Form
redis = redis.Redis()
def get_animal():
animal = redis.spop('animals')
if not animal:
redis.sadd('animals',
'human',
'bird',
'dog',
'deer',
'mouse',
'fish',
'snake',
'bear',
'cat',
'duck')
animal = redis.spop('animals')
return animal
class AnimalPlay(object):
def __init__(self):
self.now = datetime.datetime.utcnow()
self.db = Database()
self.score = make_score()
self.form = Form(self.score)
self.animal = get_animal()
self.title = 'Animal Play - {}'.format(self.animal)
# def test(self):
# self.score = make_score()
# notes = [
# Note(2, Duration(1, 16)),
# Note(4, Duration(1, 16)),
# Note(5, Duration(1, 8)),
# Note(5, Duration(1, 8)),
# Tuplet(Multiplier(2, 3), [
# Note(4, Duration(1, 16)),
# Note(5, Duration(1, 16)),
# Note(4, Duration(1, 16)),
# ]),
# Note(3, Duration(1, 8)),
# Note(0, Duration(1, 8)),
# Note(0, Duration(1, 8)),
# Note(7, Duration(1, 8)),
# ]
# beam(notes[:3])
# beam(notes[3:7])
# beam(notes[7:9])
# beam(notes[9:])
# tie(notes[2:4])
# self.score['Violin'].extend(notes)
# self.notate(parts=False, midi=True)
def notate(self, parts=True, midi=True):
notate_score(self.score, self.now, self.title, midi=midi)
if parts:
notate_parts(self.score, self.now, self.title, midi=midi)
notate_Bb_clarinet_part(self.score, self.now, self.title)
def serialize(self):
# TODO figure out other ways to serialize so I can reconstitute as a python object I can manipulate
pass
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--no-midi', dest='midi', action='store_false',
default=True, help='Do not make midi files.')
parser.add_argument('--no-parts', dest='parts', action='store_false',
default=True, help='Do not make instrument parts.')
parser.add_argument('--score', '-s', dest='score', action='store_true',
default=False, help='Make the score PDF only.')
parser.add_argument('--no-notation', '-n', dest='notation', action='store_false',
default=True, help='Do not make any notation. Just for testing.')
args = parser.parse_args()
if args.score:
args.parts = False
args.midi = False
animalplay = AnimalPlay()
if args.notation:
animalplay.notate(midi=args.midi, parts=args.parts)