11
11
def periodic ():
12
12
for i in range (0 , num_channels ):
13
13
if i in channels :
14
- channels [i ].periodic ()
14
+ channels [i ].periodic ()
15
15
16
16
num_channels = 8
17
17
reserved_channels = 0
@@ -78,11 +78,11 @@ def find_channel(force=False):
78
78
79
79
if not force :
80
80
return None
81
-
81
+
82
82
busy .sort (key = lambda x : x .play_time )
83
83
84
84
return busy [0 ]
85
-
85
+
86
86
class ChannelImpl (object ):
87
87
88
88
def __init__ (self , id ):
@@ -91,28 +91,28 @@ def __init__(self, id):
91
91
self .queued = None
92
92
93
93
self .play_time = time .time ()
94
-
94
+
95
95
def periodic (self ):
96
96
qd = sound .queue_depth (self .id )
97
97
98
98
if qd < 2 :
99
99
self .queued = None
100
-
100
+
101
101
if self .loop is not None and sound .queue_depth (self .id ) < 2 :
102
102
self .queue (self .loop , loops = 1 )
103
103
104
-
104
+
105
105
def play (self , s , loops = 0 , maxtime = 0 , fade_ms = 0 ):
106
106
if loops :
107
107
self .loop = s
108
108
109
109
sound .play (self .id , s .file , s .serial )
110
110
111
111
self .play_time = time .time ()
112
-
112
+
113
113
with condition :
114
114
condition .notify ()
115
-
115
+
116
116
117
117
def stop (self ):
118
118
self .loop = None
@@ -158,7 +158,7 @@ def queue(self, s):
158
158
def get_queue (self ):
159
159
return self .queued
160
160
161
-
161
+
162
162
def Channel (n ):
163
163
"""
164
164
Gets the channel with the given number.
@@ -174,18 +174,18 @@ def Channel(n):
174
174
175
175
sound_serial = 0
176
176
sounds = { }
177
-
177
+
178
178
class Sound (object ):
179
-
179
+
180
180
def __init__ (self , what ):
181
181
182
182
# Doesn't support buffers.
183
-
183
+
184
184
global sound_serial
185
185
186
186
self .serial = str (sound_serial )
187
187
sound_serial += 1
188
-
188
+
189
189
if isinstance (what , file ):
190
190
self .file = what
191
191
else :
@@ -231,7 +231,7 @@ class music(object):
231
231
def load (filename ):
232
232
233
233
music_channel .stop ()
234
-
234
+
235
235
global music_sound
236
236
music_sound = Sound (filename )
237
237
@@ -271,7 +271,7 @@ def get_volume():
271
271
272
272
@staticmethod
273
273
def get_busy ():
274
- return music_channel .get_volume ()
274
+ return music_channel .get_busy ()
275
275
276
276
@staticmethod
277
277
def get_pos ():
@@ -281,5 +281,5 @@ def get_pos():
281
281
def queue (filename ):
282
282
return music_channel .queue (Sound (filename ))
283
283
284
-
285
-
284
+
285
+
0 commit comments