diff options
author | Oli <olivier.belanger@umontreal.ca> | 2007-06-28 17:31:03 (GMT) |
---|---|---|
committer | Oli <olivier.belanger@umontreal.ca> | 2007-06-28 17:31:03 (GMT) |
commit | 91141480fe401a9abc4cd994a90fd8bc21980e8c (patch) | |
tree | 1a068f8094f5bf67a383c9f6e3a484403b9384ab /Edit/TrackInterface.py | |
parent | 7ef90d5655514c2c3f1177ba58d90da8451aad36 (diff) |
keyboard recording and brush tool changes
Diffstat (limited to 'Edit/TrackInterface.py')
-rw-r--r-- | Edit/TrackInterface.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Edit/TrackInterface.py b/Edit/TrackInterface.py index 5475d55..76231a9 100644 --- a/Edit/TrackInterface.py +++ b/Edit/TrackInterface.py @@ -12,7 +12,7 @@ from Edit.MainWindow import CONTEXT from Util.NoteDB import PARAMETER from Util.CSoundNote import CSoundNote - +from Generation.GenerationConstants import GenerationConstants from Util.Profiler import TP class SELECTNOTES: @@ -42,11 +42,12 @@ class TrackInterfaceParasite: class TrackInterface( gtk.EventBox ): - def __init__( self, noteDB, owner ): + def __init__( self, noteDB, owner, getScaleFunction ): gtk.EventBox.__init__( self ) self.noteDB = noteDB self.owner = owner + self.getScale = getScaleFunction self.drawingArea = gtk.DrawingArea() self.drawingAreaDirty = False # are we waiting to draw? @@ -390,6 +391,7 @@ class TrackInterface( gtk.EventBox ): TP.ProfileEnd( "TI::handleButtonPress" ) return elif self.interfaceMode == INTERFACEMODE.PAINT: + self.scale = self.getScale() self.painting = True self.paintTrack = i self.GRID = 3. @@ -409,6 +411,15 @@ class TrackInterface( gtk.EventBox ): pitch = 48 else: pitch = pitch + + minDiff = 100 + for pit in GenerationConstants.SCALES[self.scale]: + diff = abs(pitch-(pit+36)) + if diff < minDiff: + minDiff = diff + nearestPit = pit + pitch = nearestPit+36 + onset = self.pixelsToTicksFloor( self.curBeats, self.clickLoc[0] - self.trackRect[i].x ) onset = self.GRID * int(onset / self.GRID + 0.5) self.pLastPos = onset @@ -511,6 +522,13 @@ class TrackInterface( gtk.EventBox ): pitch = 48 else: pitch = pitch + minDiff = 100 + for pit in GenerationConstants.SCALES[self.scale]: + diff = abs(pitch-(pit+36)) + if diff < minDiff: + minDiff = diff + nearestPit = pit + pitch = nearestPit+36 onset = gridPos if i != self.drumIndex: |