diff options
author | Oli <olivier.belanger@umontreal.ca> | 2007-05-18 14:28:45 (GMT) |
---|---|---|
committer | Oli <olivier.belanger@umontreal.ca> | 2007-05-18 14:28:45 (GMT) |
commit | 77cdbcb8b07dbecbc94398825aab30df4cf38ba3 (patch) | |
tree | 445698fc6c77f5d297a8b993ff15ea075f58ff58 /miniTamTam | |
parent | 5f2dbdf08ff48bafa0d0c504b72c0dfc5187e9a5 (diff) |
modifier keys in miniTamTam (Left shift and Left Control)
Diffstat (limited to 'miniTamTam')
-rw-r--r-- | miniTamTam/KeyboardStandAlone.py | 23 | ||||
-rw-r--r-- | miniTamTam/miniTamTamMain.py | 21 |
2 files changed, 36 insertions, 8 deletions
diff --git a/miniTamTam/KeyboardStandAlone.py b/miniTamTam/KeyboardStandAlone.py index 83d4f73..b783070 100644 --- a/miniTamTam/KeyboardStandAlone.py +++ b/miniTamTam/KeyboardStandAlone.py @@ -22,6 +22,8 @@ class KeyboardStandAlone: self.instrument = 'flute' self.reverb = 0 self.loop = loop + self.loopSustain = False + self.sustainedLoop = [] def setInstrument( self , instrument ): self.instrument = instrument @@ -31,12 +33,22 @@ class KeyboardStandAlone: def onKeyPress(self,widget,event, volume): key = event.hardware_keycode + if key == 50: #Left Shift + self.loopSustain = True + # If the key is already in the dictionnary, exit function (to avoir key repeats) if self.key_dict.has_key(key): return if key in Config.LOOP_KEYS: - self.loop.start(key, self.instrument, self.reverb) + if key in self.sustainedLoop: + self.loop.stop(key) + self.sustainedLoop.remove(key) + elif self.loopSustain: + self.loop.start(key, self.instrument, self.reverb) + self.sustainedLoop.append(key) + else: + self.loop.start(key, self.instrument, self.reverb) return # Assign on which track the note will be created according to the number of keys pressed @@ -96,9 +108,14 @@ class KeyboardStandAlone: def onKeyRelease(self,widget,event): key = event.hardware_keycode - + if key == 50: + self.loopSustain = False + if key in Config.LOOP_KEYS: - self.loop.stop(key) + if key in self.sustainedLoop: + return + else: + self.loop.stop(key) return if KEY_MAP_PIANO.has_key(key): diff --git a/miniTamTam/miniTamTamMain.py b/miniTamTam/miniTamTamMain.py index abb2cc5..5b09629 100644 --- a/miniTamTam/miniTamTamMain.py +++ b/miniTamTam/miniTamTamMain.py @@ -46,6 +46,7 @@ class miniTamTamMain(SubActivity): self.reverb = 0. self.tempo = Config.PLAYER_TEMPO self.rythmInstrument = 'drum1kit' + self.muteInst = False self.drumFillin = Fillin( self.beat, self.tempo, self.rythmInstrument, self.reverb, self.drumVolume ) self.regenerate() self.sequencer= MiniSequencer(self.recordStateButton) @@ -400,7 +401,8 @@ class miniTamTamMain(SubActivity): self.keyboardStandAlone.setInstrument(instrument) def playInstrumentNote(self , instrument, secs_per_tick = 0.025): - self.csnd.play( + if not self.muteInst: + self.csnd.play( CSoundNote( onset = 0, pitch = 36, amplitude = 1, @@ -421,12 +423,21 @@ class miniTamTamMain(SubActivity): self.handlePlayButton(self.playStopButton) self.playStopButton.set_active(True) - if event.hardware_keycode == 65: #what key is this? what feature is this? - if self.playStopButton.get_active(): - self.playStopButton.set_active(False) + if event.hardware_keycode == 37: + if self.muteInst: + self.muteInst = False else: - self.playStopButton.set_active(True) + self.muteInst = True + + if event.hardware_keycode == 65: #what key is this? what feature is this? + pass + #if self.playStopButton.get_active(): + #self.playStopButton.set_active(False) + #else: + #self.playStopButton.set_active(True) + self.keyboardStandAlone.onKeyPress(widget, event, sqrt( self.instVolume*0.01 )) + def onKeyRelease(self, widget, event): self.keyboardStandAlone.onKeyRelease(widget, event) |