-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
68 lines (52 loc) · 1.75 KB
/
main.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
import midi
from random import choice, random
from listener import Listener
from neoscore.common import *
path_to_midi_file = "media/A_Sleepin_Bee.mid" # <--- change this to your file
class UI:
"""INSERT DOCSTRING HERE"""
def __init__(self):
"""INSERT DOCSTRING HERE"""
#
self.midilist = midi.get_midi_lists(path_to_midi_file)
print(f"Midilist contents: {self.midilist}")
#
neoscore.setup()
#
annotation = "DEMO digital score BLAH BLAH"
RichText((Mm(1), Mm(1)), None, annotation, width=Mm(170))
#
staff = Staff((ZERO, Mm(70)), None, Mm(180), line_spacing=Mm(5))
unit = staff.unit
clef = Clef(ZERO, staff, "treble")
#
self.center = unit(20)
#
self.n1 = Chordrest(self.center, staff, ["g"], Duration(1, 4))
self.n2 = Chordrest(self.center, staff, ["b"], Duration(1, 4))
self.n3 = Chordrest(self.center, staff, ["d'"], Duration(1, 4))
self.n4 = Chordrest(self.center, staff, ["f'"], Duration(1, 4))
#
self.note_list = (self.n1, self.n2, self.n3, self.n4)
#
self.ear = Listener()
self.ear.start()
def refresh_func(self, time):
"""INSERT DOCSTRING HERE"""
#
rnd_note = choice(self.note_list)
if random() >= 0.5:
new_pitch = choice(self.midilist)
else:
new_pitch = self.ear.neonote
#
try:
rnd_note.notes = [new_pitch]
except:
pass
if __name__ == "__main__":
run = UI()
neoscore.set_refresh_func(run.refresh_func, target_fps=1)
neoscore.show(display_page_geometry=False,
auto_viewport_interaction_enabled=False
)