Skip to content

Instantly share code, notes, and snippets.

@sirpercival
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirpercival/b4e19740cbc286bdf5b6 to your computer and use it in GitHub Desktop.
Save sirpercival/b4e19740cbc286bdf5b6 to your computer and use it in GitHub Desktop.
from kivy.app import App
from kivy.lang import Builder
from kivy.core.audio import SoundLoader
from kivy.uix.widget import Widget
from kivy.core.window import Window
kv = '''
<SoundBoard>:
GridLayout:
rows: 5
Label:
text: "Q: sound01"
Label:
text: "W: sound02"
Label:
text: "E: sound03"
Label:
text: "R: sound04"
Label:
text: "T: sound05"
Label:
text: "A: sound06"
Label:
text: "S: sound07"
Label:
text: "D: sound08"
Label:
text: "F: sound09"
Label:
text: "G: sound10"
Label:
text: "Z: sound11"
Label:
text: "X: sound12"
Label:
text: "C: sound13"
Label:
text: "V: sound14"
Label:
text: "B: sound15"
'''
class SoundBoard(Widget):
def __init__(self, **kwargs):
super(SoundBoard, self).__init__(**kwargs)
self._keyboard = Window.request_keyboard(
self._keyboard_closed, self, 'text')
self._keyboard.bind(on_key_down=self._on_keyboard_down)
self.sound_effects = {
'q':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test1.wav'),
'w':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test2.wav'),
'e':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test3.wav'),
'r':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test1.wav'),
't':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test2.wav'),
'a':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test3.wav'),
's':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test1.wav'),
'd':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test2.wav'),
'f':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test3.wav'),
'g':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test1.wav'),
'z':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test2.wav'),
'x':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test3.wav'),
'c':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test1.wav'),
'v':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test2.wav'),
'b':SoundLoader.load('/Users/gray/Desktop/evildeadsounds/test3.wav')}
def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
self.sound_effects[text].play()
def _keyboard_closed(self):
pass
Builder.load_string(kv)
class SoundboardApp(App):
def build(self):
return SoundBoard()
if __name__ == '__main__':
SoundboardApp().run()
[INFO ] [Logger ] Record log in /Users/gray/.kivy/logs/kivy_14-10-23_10.txt
[INFO ] Kivy v1.8.1-dev
[INFO ] [Python ] v2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
[INFO ] [Factory ] 169 symbols loaded
[DEBUG ] [Cache ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60s
[DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=Nones
[DEBUG ] [Image ] option <imageio> ignored by config
[DEBUG ] [Image ] option <tex> ignored by config
[DEBUG ] [Image ] option <dds> ignored by config
[DEBUG ] [Image ] option <pil> ignored by config
[INFO ] [Image ] Providers: img_pygame, img_gif (img_imageio, img_tex, img_dds, img_pil ignored)
[DEBUG ] [Cache ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG ] [Cache ] register <kv.shader> with limit=1000, timeout=3600s
[DEBUG ] [Audio ] register SoundPygame
[INFO ] [Audio ] Providers: audio_pygame (audio_pygst, audio_ffpyplayer, audio_sdl ignored)
[DEBUG ] [Window ] Ignored <egl_rpi> (import error)
[INFO ] [Window ] Provider: pygame(['window_egl_rpi'] ignored)
[DEBUG ] [Window ] Display driver Quartz
[DEBUG ] [Window ] Actual window size: 800x600
[DEBUG ] [Window ] Actual color bits r8 g8 b8 a8
[DEBUG ] [Window ] Actual depth bits: 24
[DEBUG ] [Window ] Actual stencil bits: 8
[DEBUG ] [Window ] Actual multisampling samples: 4
[INFO ] [GL ] OpenGL version <2.1 INTEL-8.26.34>
[INFO ] [GL ] OpenGL vendor <Intel Inc.>
[INFO ] [GL ] OpenGL renderer <Intel HD Graphics 4000 OpenGL Engine>
[INFO ] [GL ] OpenGL parsed version: 2, 1
[INFO ] [GL ] Shading version <1.20>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <16>
[DEBUG ] [Shader ] Fragment compiled successfully
[DEBUG ] [Shader ] Vertex compiled successfully
[DEBUG ] [ImagePygame ] Load </Applications/Kivy.app/Contents/Resources/kivy/kivy/data/glsl/default.png>
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[DEBUG ] [App ] Loading kv <./soundboard.kv>
[DEBUG ] [App ] kv <./soundboard.kv> not found
[INFO ] [Text ] Provider: pygame
python2.7(97262,0x7fff7eb1b310) malloc: *** error for object 0x10ab18ae0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment