From 4e88ccebc8cd09fe19939c3d0c631f2bb076b1c6 Mon Sep 17 00:00:00 2001 From: olipet Date: Wed, 10 Jan 2007 00:02:46 +0000 Subject: syntax bug --- (limited to 'Player') diff --git a/Player/RythmPlayer.py b/Player/RythmPlayer.py index 96708a8..a0d7a1d 100644 --- a/Player/RythmPlayer.py +++ b/Player/RythmPlayer.py @@ -2,14 +2,12 @@ import pygtk pygtk.require( '2.0' ) import gtk import gobject - +import time import Config from Util.CSoundNote import CSoundNote -from Util.CSoundClient import CSoundClient class RythmPlayer: - def __init__( self, client, recordButtonState ): - self.csnd = client + def __init__( self, recordButtonState, getTick ): self.notesList = [] self.sequencer = [] self.pitchs = [] @@ -19,12 +17,13 @@ class RythmPlayer: self.startLooking = 0 self.recordState = 0 self.recordButtonState = recordButtonState + self.getTick = getTick self.playbackTimeout = None self.beat = 4 self.playState = 0 - def getCurrentTick(self): - return self.currentTick + def getCurrentTick( self ): + return self.getTick(time.time, True) def setTempo( self, tempo ): self.tempo = tempo @@ -43,40 +42,33 @@ class RythmPlayer: def recording( self, note ): if self.recordState: self.pitchs.append( note.pitch ) - note.onset = self.currentTick + note.onset = self.getTick(time.time, True) self.sequencer.append( note ) def adjustDuration( self, pitch, onset ): if pitch in self.pitchs: - offset = self.currentTick + offset = self.getTick(time.time, True) for note in self.sequencer: if note.pitch == pitch and note.onset == onset: - if offset > note.onset: - note.duration = offset - note.onset - else: - note.duration = (offset+(self.beat*12)) - note.onset + if offset > note.onset: + note.duration = offset - note.onset + else: + note.duration = (offset+(self.beat*12)) - note.onset self.pitchs.remove( pitch ) - def playing( self ): - return self.playbackTimeout != None - def startPlayback( self ): if not self.playState: - self.playbackTimeout = gobject.timeout_add( int(60000/self.tempo/12) , self.handleClock ) - self.handleClock() self.playState = 1 def stopPlayback( self ): - if self.playbackTimeout != None: - gobject.source_remove( self.playbackTimeout ) - self.playbackTimeout = None + if self.playState: self.playState = 0 def handleClock( self ) : if self.sequencer and self.sequencerPlayback: for note in self.sequencer: - if note.onset == self.currentTick: - note.play() + if note.onset == self.getTick(time.time, True): + note.play() if self.startLooking: self.sequencerPlayback = 0 @@ -84,21 +76,18 @@ class RythmPlayer: self.recordButtonState(True) if self.currentTick in self.upBeats: self.recordButtonState(False) - if self.currentTick == 0: + if self.getTick(time.time, True) == 0: self.sequencer = [] self.pitchs = [] self.recordState = 1 self.startLooking = 0 - self.currentTick = self.currentTick + 1 - if self.currentTick >= (Config.TICKS_PER_BEAT * self.beat): + if self.getTick(time.time, True) >= (Config.TICKS_PER_BEAT * self.beat): if self.recordState: self.recordState = 0 self.sequencerPlayback = 1 self.recordButtonState(False) - self.currentTick = 0 - return True diff --git a/Player/StandalonePlayer.py b/Player/StandalonePlayer.py index 9ecf3fd..f5828b2 100644 --- a/Player/StandalonePlayer.py +++ b/Player/StandalonePlayer.py @@ -35,9 +35,9 @@ class StandAlonePlayer( gtk.EventBox ): self.regularity = 0.75 self.beat = 4 self.tempo = Config.PLAYER_TEMPO - self.rythmPlayer = RythmPlayer(self.csnd, self.recordStateButton) self.rythmInstrument = 'drum1kit' self.noteLooper = NoteLooper( Config.NOTELOOPER_HORIZON, self.tempo * Config.TICKS_PER_BEAT / 60.0 ) + self.rythmPlayer = RythmPlayer(self.recordStateButton, self.noteLooper.getTick) self.notesList = [] self.csnd.startTime() self.noteLooper.startTime() -- cgit v0.9.1