Added logging.

master
q3k 2013-07-14 17:48:31 +02:00
parent d91a4ddd8f
commit 64ef9b6ae6
1 changed files with 8 additions and 4 deletions

12
host.py
View File

@ -23,14 +23,16 @@ MAPPING = [
0
]
SPATH = "/mnt/nas/Projects/soundboard/sounds/"
SPATH = "sounds/"
class SimpleSound:
def __init__(self, path):
self.path = path
def create(self):
print("Loading {}".format(self.path))
self.s = pygame.mixer.Sound(SPATH + self.path)
def play(self):
print("Playing {}".format(self.path))
self.s.play()
return self.s.get_length() * 0.5
@ -38,9 +40,11 @@ class RandomSound:
def __init__(self, paths):
self.paths = paths
def create(self):
self.sounds = [pygame.mixer.Sound(SPATH + p) for p in self.paths]
print("Loading {}".format(", ".join(self.paths)))
self.sounds = [(pygame.mixer.Sound(SPATH + p), p) for p in self.paths]
def play(self):
s = random.choice(self.sounds)
s, path = random.choice(self.sounds)
print("Playing {}".format(path))
print(s)
s.play()
return s.get_length() * 0.5
@ -70,7 +74,7 @@ if __name__ == "__main__":
pygame.joystick.init()
j = pygame.joystick.Joystick(0)
j.init()
print("Ready!")
while True:
pygame.event.pump()