-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstrument.py
More file actions
79 lines (72 loc) · 2.44 KB
/
Copy pathInstrument.py
File metadata and controls
79 lines (72 loc) · 2.44 KB
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
from collections import defaultdict
class Instrument:
pitches = ['F_sharp_3',
'G3',
'G_sharp_3',
'A3',
'A_sharp_3',
'B3',
'C4',
'C_sharp_4',
'D4',
'D_sharp_4',
'E4',
'F4',
'F_sharp_4',
'G4',
'G_sharp_4',
'A4',
'A_sharp_4',
'B4',
'C5',
'C_sharp_5',
'D5',
'D_sharp_5',
'E5',
'F5',
'F_sharp_5']
noteLoc = defaultdict() # will be generated once genNoteBlocks called
def genNoteBlocks(self):
'''
Generates xml for note blocks and
save location of pressure plate for the note block in noteLoc
'''
xml = ""
notes = self.getNotes()
num_notes = self.getNoteCount()
for index, note in enumerate(notes):
xml += '''<DrawBlock type="noteblock"
variant="{cur_note}"
x="15"
y="56"
z="{z_loc}" />
<DrawBlock type="wooden_pressure_plate"
x="14"
y="56"
z="{z_loc}" />'''.format(cur_note=note, z_loc=num_notes-index)
self.noteLoc[note] = (13, index+.5)
print(self.noteLoc)
return xml
def getNotes(self):
'''
Return list of all the pitches
'''
return self.pitches
def getNoteCount(self):
''' Return count of the pitches '''
return len(self.pitches)
def getNotePos(self, note):
''' Return the location of the pressure plate for the note block'''
return self.noteLoc[note]
def runScale(self):
'''
Returns list of note locations for teleportation, playing all the notes sequentially
Ex. [(13,1.5), (13,2.5)]
'''
command = list()
for note in self.pitches:
x_loc, z_loc = self.noteLoc[note]
#tp_command = "tp " + str(x_loc) + " 57 " + str(z_loc)
#command.append(tp_command)
command.append(self.noteLoc[note])
return command