-
Notifications
You must be signed in to change notification settings - Fork 2
/
audioInfo.py
135 lines (104 loc) · 4.46 KB
/
audioInfo.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/python
#from audioEvent import AudioEvent
from sys import maxint
from random import randint
# Stores Music library and returns appropriate songs
# SUPER HACKY... SHOUDL REALLY IMPORT sounds.py BUT TIRED AND SLOPPY RIGHT NOW
DAY1_LOW = range(1,8)
DAY1_MID = range(7, 57)
DAY1_HIGH = range(1000,1020)
DAY2_LOW = range(2100,2106)
DAY2_MID = range(100, 160)
DAY2_HIGH = range(1100,1136)
DAY3_LOW = range(2200,2208)
DAY3_MID = range(1200, 1278)
DAY3_HIGH = range(200, 218)
DAY4_LOW = range(2300,2304)
DAY4_MID = range(1300,1377)
DAY4_HIGH = range(300,307)
DAY5_LOW = range(2500, 2513)
DAY5_MID = range(501, 588)
DAY5_HIGH = range(1500, 1513)
DAY6_LOW = range(2600, 2611)
DAY6_MID = range(600, 650)
DAY6_HIGH = range(1600, 1617)
DAY7_LOW = range(2700, 2705)
DAY7_MID = range(1700,1775)
DAY7_HIGH = range(700,715)
class AudioFileInfo:
def __init__(self, name, index, category, events = [], animations = []):
self.name = name
self.category = category
self.file_index = index
self.events = events
self.event_index = 0
self.animations = animations
def __repr__(self):
return "%s AudioFileInfo '%s' named_category:%s animations: [%s] events: [%s]" % (self.file_index, self.name, self.category, self.animations, self.events)
def __str__(self):
return "%s AudioFileInfo '%s' named_category:%s animations: [%s] events: [%s]" % (self.file_index, self.name, self.category, self.animations, self.events)
def addAnimation(self, animation):
self.animations.append(animation)
def getAudioDay(self):
out = -1
if(int(self.file_index) in DAY1_LOW or int(self.file_index) in DAY1_MID or int(self.file_index) in DAY1_HIGH):
out = 0
elif(int(self.file_index) in DAY2_LOW or int(self.file_index) in DAY2_MID or int(self.file_index) in DAY2_HIGH):
out = 1
elif(int(self.file_index) in DAY3_LOW or int(self.file_index) in DAY3_MID or int(self.file_index) in DAY3_HIGH):
out = 2
elif(int(self.file_index) in DAY4_LOW or int(self.file_index) in DAY4_MID or int(self.file_index) in DAY4_HIGH):
out = 3
elif(int(self.file_index) in DAY5_LOW or int(self.file_index) in DAY5_MID or int(self.file_index) in DAY5_HIGH):
out = 4
elif(int(self.file_index) in DAY6_LOW or int(self.file_index) in DAY6_MID or int(self.file_index) in DAY6_HIGH):
out = 5
elif(int(self.file_index) in DAY7_LOW or int(self.file_index) in DAY7_MID or int(self.file_index) in DAY7_HIGH):
out = 6
print "audio day: " + str(out)
return out
def getNumericalCategory(self):
out = -1
if(self.category == "LOW"):
out = 0
elif(self.category == "MID"):
out = 1
elif(self.category == "HIGH"):
out = 2
print "audio cat num: " + str(out)
return out
def getRandomSuitableAnimation(self):
if len(self.animations) > 0:
return self.animations[randint(0, len(self.animations))]
#return None
#HACK UNTIL CAN GET REAL VALUES POPULATED
if self.category == "LOW":
return randint(1,3) # number of base animations
if self.category == "MID":
return randint(1,13) # number of mid animations
#high
return randint(1,10) # number of sparkle animations
def addEvent(self, event):
self.events.append(event)
def getNextEvent(self):
if self.event_index < len(self.events):
event = self.events[self.event_index]
self.event_index += 1
return event
return None
class AudioEvent:
'a class to hold an audio event info'
def __init__(self, time, magnitude, kind, category, exec_time=0):
self.time = time
self.magnitude = magnitude
self.kind = kind
self.category = category
self.exec_time = exec_time
def __dict__(self):
return {"time": self.time, "magnitude": self.magnitude, "kind": self.kind, "category": self.category}
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __str__(self):
return "kind: %s, time: %s, magnitude: %s, category: %s, exec_time: %s" % (self.kind, self.time, self.magnitude, self.category, self.exec_time)
def __repr__(self):
return "kind: %s, time: %s, magnitude: %s, category: %s, exec_time: %s" % (self.kind, self.time, self.magnitude, self.category, self.exec_time)