Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/KeyboardStandAlone.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-10-09 03:29:34 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-10-09 03:29:34 (GMT)
commit80160cd8b6eff9d36419d5be78b4098128f33ad1 (patch)
tree1048d3a5bd64ab937d7ea766257bcb18086b78ed /KeyboardStandAlone.py
parent70f861a21b026057b5642ca9c7c9b125acf62be8 (diff)
Use the keyboard in the screen to play sounds
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'KeyboardStandAlone.py')
-rw-r--r--KeyboardStandAlone.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/KeyboardStandAlone.py b/KeyboardStandAlone.py
index 6a8272a..d661808 100644
--- a/KeyboardStandAlone.py
+++ b/KeyboardStandAlone.py
@@ -33,8 +33,11 @@ class KeyboardStandAlone:
def setReverb(self , reverb):
self.reverb = reverb
- def onKeyPress(self,widget,event, volume):
+ def onKeyPress(self, widget, event, volume):
key = event.hardware_keycode
+ self.do_key_press(key, event.state, volume)
+
+ def do_key_press(self, key, state, volume):
if key == 50 or key == 62: #Left Shift
self.loopSustain = True
@@ -100,7 +103,7 @@ class KeyboardStandAlone:
playkey(36,100, self.instrumentDB.instNamed[instrumentName].kit[pitch])
else:
- if event.state == Gdk.ModifierType.MOD1_MASK:
+ if state == Gdk.ModifierType.MOD1_MASK:
pitch += 5
instrument = self.instrumentDB.instNamed[ instrumentName ]
@@ -110,8 +113,11 @@ class KeyboardStandAlone:
playkey( pitch, -1, instrument)
- def onKeyRelease(self,widget,event):
+ def onKeyRelease(self, widget, event):
key = event.hardware_keycode
+ self.do_key_release(key)
+
+ def do_key_release(self, key):
if key == 50 or key == 62:
self.loopSustain = False