commit d91a4ddd8f654221dab407e499c640925fe4c0d0 Author: Sergiusz 'q3k' BazaƄski Date: Sun Jul 14 17:45:54 2013 +0200 Initial commit. Code kind of works. diff --git a/host.py b/host.py new file mode 100644 index 0000000..5372340 --- /dev/null +++ b/host.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 + +import sys +import time +import random +import pygame + +from pygame.locals import * + +# "we'll fix it in post!" +MAPPING = [ + 8, + 7, + 6, + 5, + 1, + 2, + 3, + 4, + 9, + 10, + 11, + 0 +] + +SPATH = "/mnt/nas/Projects/soundboard/sounds/" + +class SimpleSound: + def __init__(self, path): + self.path = path + def create(self): + self.s = pygame.mixer.Sound(SPATH + self.path) + def play(self): + self.s.play() + return self.s.get_length() * 0.5 + +class RandomSound: + def __init__(self, paths): + self.paths = paths + def create(self): + self.sounds = [pygame.mixer.Sound(SPATH + p) for p in self.paths] + def play(self): + s = random.choice(self.sounds) + print(s) + s.play() + return s.get_length() * 0.5 + +SOUNDS = [ + SimpleSound("nope.wav"), + SimpleSound("yesyes.wav"), + SimpleSound("ba-dum-tish.wav"), + SimpleSound("crickets.wav"), + SimpleSound("wind.wav"), + SimpleSound("trombone.wav"), + RandomSound(["whip.wav", "whip2.wav", "whip4.wav"]), + SimpleSound("finishim.wav"), + SimpleSound("wtfboom.wav"), + SimpleSound("noooooooo.wav"), + SimpleSound("fanfare.wav"), + SimpleSound("dundundun.wav"), +] + +play_again_at = time.time() + + +if __name__ == "__main__": + pygame.init() + for s in SOUNDS: + s.create() + pygame.joystick.init() + j = pygame.joystick.Joystick(0) + j.init() + + + while True: + pygame.event.pump() + for event in pygame.event.get(): + if event.type == JOYBUTTONDOWN: + n = MAPPING.index(event.button) + if n < len(SOUNDS) and time.time() >= play_again_at: + play_again_at = time.time() + SOUNDS[n].play() + + time.sleep(0.1) diff --git a/sounds/ba-dum-tish.wav b/sounds/ba-dum-tish.wav new file mode 100644 index 0000000..5b9b696 Binary files /dev/null and b/sounds/ba-dum-tish.wav differ diff --git a/sounds/crickets.wav b/sounds/crickets.wav new file mode 100755 index 0000000..1c19570 Binary files /dev/null and b/sounds/crickets.wav differ diff --git a/sounds/dundundun.wav b/sounds/dundundun.wav new file mode 100755 index 0000000..c52aa17 Binary files /dev/null and b/sounds/dundundun.wav differ diff --git a/sounds/fanfare.wav b/sounds/fanfare.wav new file mode 100755 index 0000000..cf21d33 Binary files /dev/null and b/sounds/fanfare.wav differ diff --git a/sounds/fight.wav b/sounds/fight.wav new file mode 100755 index 0000000..6eb79ac Binary files /dev/null and b/sounds/fight.wav differ diff --git a/sounds/finishim.wav b/sounds/finishim.wav new file mode 100755 index 0000000..088ec7b Binary files /dev/null and b/sounds/finishim.wav differ diff --git a/sounds/noooooooo.wav b/sounds/noooooooo.wav new file mode 100755 index 0000000..0b2e9db Binary files /dev/null and b/sounds/noooooooo.wav differ diff --git a/sounds/nope.wav b/sounds/nope.wav new file mode 100755 index 0000000..0a62d0e Binary files /dev/null and b/sounds/nope.wav differ diff --git a/sounds/partyalarm.wav b/sounds/partyalarm.wav new file mode 100755 index 0000000..7bd6234 Binary files /dev/null and b/sounds/partyalarm.wav differ diff --git a/sounds/trombone.wav b/sounds/trombone.wav new file mode 100755 index 0000000..7a16638 Binary files /dev/null and b/sounds/trombone.wav differ diff --git a/sounds/whip.wav b/sounds/whip.wav new file mode 100755 index 0000000..aa02c6e Binary files /dev/null and b/sounds/whip.wav differ diff --git a/sounds/whip2.wav b/sounds/whip2.wav new file mode 100755 index 0000000..1159c14 Binary files /dev/null and b/sounds/whip2.wav differ diff --git a/sounds/whip3.wav b/sounds/whip3.wav new file mode 100755 index 0000000..18dcf60 Binary files /dev/null and b/sounds/whip3.wav differ diff --git a/sounds/whip4.wav b/sounds/whip4.wav new file mode 100755 index 0000000..083ba93 Binary files /dev/null and b/sounds/whip4.wav differ diff --git a/sounds/wind.wav b/sounds/wind.wav new file mode 100755 index 0000000..856faf1 Binary files /dev/null and b/sounds/wind.wav differ diff --git a/sounds/wtfboom.wav b/sounds/wtfboom.wav new file mode 100755 index 0000000..183ba97 Binary files /dev/null and b/sounds/wtfboom.wav differ diff --git a/sounds/yesyes.wav b/sounds/yesyes.wav new file mode 100755 index 0000000..48b6f94 Binary files /dev/null and b/sounds/yesyes.wav differ