-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.py
72 lines (53 loc) · 2.28 KB
/
generator.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
from rhythm import Rhythm
from pitch import Pitch
from writer import Writer
from renderer import Renderer
import cameraDistortion
from data import Data
class Generator:
def generator(args, score):
number_measures = args.measures
space = Rhythm.getMinRhythm(score["measure"])
number_voices = args.voices
voice_counter = 0
#print(score["measure"])
"""
Score[voices] will be an array of voices that are an array of measures
each of them an array of notes.
"""
score["voices"] = []
while(voice_counter != number_voices):
voice_container = []
measures_counter = 0
while(measures_counter != number_measures):
notes_in_measure = []
current_space = space
while(current_space != 0.0):
note = {}
r, tam = Rhythm.getRhythm(current_space)
current_space -= tam
if isinstance(r, list):
for item in r:
note["rhythm"] = item
note["note_idx"] = -1
notes_in_measure.append(note.copy())
else:
note["rhythm"] = r
note["note_idx"] = -1
notes_in_measure.append(note.copy())
# END OF MEASURE OF A VOICE
measures_counter += 1
voice_container.append(notes_in_measure)
# END OF VOICE
score["voices"].append(voice_container)
voice_counter += 1
score = Pitch.createPitches(score)
if args.lyrics > 0:
score['lyrics'] = []
Writer.write(score)
Renderer.renderScore("example.krn", "example.svg")
#Renderer.renderScoreWithOtherFont("example.svg")
if Data.camera:
cameraDistortion.apply_distortion(path="example.png", saving_path="cameraExample.png", bg_change=False)
if Data.change_background:
cameraDistortion.apply_distortion(path="pruebaFondo.png", saving_path="cameraFondoExample.png", bg_change=True)