diff options
author | olipet <olpc@localhost.localdomain> | 2007-01-12 23:37:52 (GMT) |
---|---|---|
committer | olipet <olpc@localhost.localdomain> | 2007-01-12 23:37:52 (GMT) |
commit | c7d792a296822298082b4e21488b0ff07d7fc727 (patch) | |
tree | ae6ece0db124cfc1f7589e86f077755699e9839c /Player | |
parent | 40f0f34841c4aa23fe9fc06e5a0bef075a72079f (diff) |
keyboard fix ( introduce by sequencer )
Diffstat (limited to 'Player')
-rw-r--r-- | Player/KeyboardStandAlone.py | 19 | ||||
-rw-r--r-- | Player/RythmPlayer.py | 3 | ||||
-rw-r--r-- | Player/StandalonePlayer.py | 4 |
3 files changed, 17 insertions, 9 deletions
diff --git a/Player/KeyboardStandAlone.py b/Player/KeyboardStandAlone.py index 9baa1da..6976754 100644 --- a/Player/KeyboardStandAlone.py +++ b/Player/KeyboardStandAlone.py @@ -10,11 +10,12 @@ from Util.CSoundNote import CSoundNote KEY_MAP_PIANO = Config.KEY_MAP_PIANO class KeyboardStandAlone: - def __init__( self, client, recordingFunction, adjustDurationFunction, getCurrentTick ): + def __init__( self, client, recordingFunction, adjustDurationFunction, getCurrentTick, getPlayState ): self.csnd = client self.recording = recordingFunction self.adjustDuration = adjustDurationFunction self.getCurrentTick = getCurrentTick + self.getPlayState = getPlayState self.key_dict = dict() self.onset_dict = dict() self.trackCount = 10 @@ -76,9 +77,10 @@ class KeyboardStandAlone: instrumentFlag = instrument, reverbSend = self.reverb) self.csnd.sendText( self.key_dict[key].getText(0.3,0)) #play - recOnset = self.getCurrentTick() / 3 - self.onset_dict[key] = recOnset - self.recording( CSoundNote( + if self.getPlayState(): + recOnset = self.getCurrentTick() / 3 + self.onset_dict[key] = recOnset + self.recording( CSoundNote( onset = recOnset, pitch = pitch, amplitude = 1, @@ -100,13 +102,14 @@ class KeyboardStandAlone: self.key_dict[key].decay = 0.7 self.key_dict[key].amplitude = 1 self.csnd.sendText( self.key_dict[key].getText(0.3,0)) #play - - self.adjustDuration(self.key_dict[key].pitch, self.onset_dict[key]) + if self.getPlayState(): + self.adjustDuration(self.key_dict[key].pitch, self.onset_dict[key]) del self.key_dict[key] else: del self.key_dict[key] - if self.onset_dict.has_key(key): - del self.onset_dict[key] + if self.getPlayState(): + if self.onset_dict.has_key(key): + del self.onset_dict[key] def onButtonPress( self, widget, event ): pass diff --git a/Player/RythmPlayer.py b/Player/RythmPlayer.py index ff5bc30..35b1afa 100644 --- a/Player/RythmPlayer.py +++ b/Player/RythmPlayer.py @@ -42,6 +42,9 @@ class RythmPlayer: self.realTick = [i for i in range(self.beat*4)] self.startLooking = 1 + def getPlayState( self ): + return self.playState + def startPlayback( self ): if not self.playState: self.playbackTimeout = gobject.timeout_add( int(60000/self.tempo/12), self.handleClock ) diff --git a/Player/StandalonePlayer.py b/Player/StandalonePlayer.py index f92fab9..52d9f88 100644 --- a/Player/StandalonePlayer.py +++ b/Player/StandalonePlayer.py @@ -5,6 +5,7 @@ import gobject import os import random import time +from types import * import Config @@ -354,6 +355,7 @@ class StandAlonePlayer( gtk.EventBox ): if data == 'lab1': num = 1 self.synthLabWindow1.show_all() + self.synthLabWindow1.set_keep_above(True) elif data == 'lab2': num = 2 self.synthLabWindow2.show_all() @@ -454,7 +456,7 @@ class StandAlonePlayer( gtk.EventBox ): self.playStartupSound() def enableKeyboard( self ): - self.keyboardStandAlone = KeyboardStandAlone( self.csnd, self.rythmPlayer.recording, self.rythmPlayer.adjustDuration, self.rythmPlayer.getCurrentTick ) + self.keyboardStandAlone = KeyboardStandAlone( self.csnd, self.rythmPlayer.recording, self.rythmPlayer.adjustDuration, self.rythmPlayer.getCurrentTick, self.rythmPlayer.getPlayState ) self.add_events(gtk.gdk.BUTTON_PRESS_MASK) def setInstrument( self , instrument ): |