Skip to content
This repository has been archived by the owner on Aug 29, 2022. It is now read-only.

Commit

Permalink
more consistent but resource heavy audio playback
Browse files Browse the repository at this point in the history
  • Loading branch information
RiedleroD committed Sep 7, 2020
1 parent 707eff4 commit 7d74706
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from Entities import *
from Algs import *
import traceback as tbe
from collections import deque

class GameWin(pyglet.window.Window):
def __init__(self,*args,**kwargs):
Expand All @@ -19,7 +20,8 @@ def __init__(self,*args,**kwargs):
self.rads=[]
self.edits=[]
self.bucks=[]
self.apls=[pyglet.media.Player() for i in range(25)]#audio players
self.toplay=deque()
self.apls=[pyglet.media.Player() for i in range(10)]#audio players
for apl in self.apls:
apl.volume=0.1
self.batch=pyglet.graphics.Batch()
Expand Down Expand Up @@ -104,12 +106,21 @@ def update(self,dt):
self.labels[4].setText("Insert:%02i"%self.stats[2])
self.labels[5].setText("Bucket:%02i"%self.stats[3])
self.labels[6].setText("Pass:%02i"%self.stats[4])
def play(self,item):
self.play_all()
def play_all(self):
for i,apl in enumerate(self.apls):
if self.toplay:
item=self.toplay.pop()
else:
return
if apl.playing:
apl.next_source()
apl.queue(AUDIOS[item])
if not apl.playing:
apl.queue(AUDIOS[item])
apl.play()
return
self.toplay.clear()
def play(self,item):
self.toplay.append(item)
def play_index(self,b,i):
return self.play(self.bucks[b]._getvalue(i)[1])
def act_read(self,act):
Expand Down

0 comments on commit 7d74706

Please sign in to comment.