Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TamTamEdit.activity/Edit/MainWindow.py
diff options
context:
space:
mode:
authorOli <olivier.belanger@umontreal.ca>2007-09-21 00:13:06 (GMT)
committer Oli <olivier.belanger@umontreal.ca>2007-09-21 00:13:06 (GMT)
commit72610bcaf281600e9925d65db8f9af89b14e558e (patch)
tree3712615fcb12b7a8b5ed273ecf5d63531363ea4e /TamTamEdit.activity/Edit/MainWindow.py
parent05958007515277d0adcd9ae161c12ddb0cfb6426 (diff)
meta algo
Diffstat (limited to 'TamTamEdit.activity/Edit/MainWindow.py')
-rw-r--r--TamTamEdit.activity/Edit/MainWindow.py67
1 files changed, 32 insertions, 35 deletions
diff --git a/TamTamEdit.activity/Edit/MainWindow.py b/TamTamEdit.activity/Edit/MainWindow.py
index f79a8f2..49125a4 100644
--- a/TamTamEdit.activity/Edit/MainWindow.py
+++ b/TamTamEdit.activity/Edit/MainWindow.py
@@ -59,7 +59,7 @@ class MainWindow( gtk.EventBox ):
# META ALGO: [section, variation or not, nPages] A B A C
# TODO: Different parameters sets for each tracks
self.tuneForm = [[0, False, 4], [1, False, 4], [0, True, 4], [2, False, 2]]
-
+
def init_data( ):
TP.ProfileBegin("init_data")
self._data = {}
@@ -78,7 +78,7 @@ class MainWindow( gtk.EventBox ):
self.trackInstrument = self.trackInstrumentDefault[:]
if len(self.trackInstrument) != Config.NUMBER_OF_TRACKS: raise 'error'
self.drumIndex = Config.NUMBER_OF_TRACKS - 1
-
+
self.last_clicked_instTrackID = 0
self.last_clicked_instPrimary = 'kalimba'
@@ -250,7 +250,7 @@ class MainWindow( gtk.EventBox ):
self.GUI["2drumButton"] = ImageToggleButton(Config.IMAGE_ROOT + self.trackInstrument[4].name + '.png', Config.IMAGE_ROOT + self.trackInstrument[4].name + '.png')
self.GUI["2drumPalette"] = instrumentPalette(_('Track 5 Volume'), self, 4)
self.GUI["2drumButton"].set_palette(self.GUI["2drumPalette"])
- self.GUI["2drumButton"].connect("toggled", self.pickDrum)
+ self.GUI["2drumButton"].connect("toggled", self.pickDrum)
self.GUI["2drumBox"].pack_start( self.GUI["2drumButton"] )
self.GUI["2instrumentPanel"].pack_start( self.GUI["2drumBox"] )
self.GUI["2page"].pack_start( self.GUI["2instrumentPanel"], False )
@@ -501,13 +501,13 @@ class MainWindow( gtk.EventBox ):
Config.INSTRUMENTS[random.choice(drumsPickup)] ]
def chooseGenParams(self):
- choose = random.randint(0,4)
- density = GenerationConstants.RYTHM_DENSITY_BANK[choose]
- rytReg = GenerationConstants.RYTHM_REGU_BANK[choose]
- step = GenerationConstants.PITCH_STEP_BANK[choose]
- pitReg = GenerationConstants.PITCH_REGU_BANK[choose]
- dur = GenerationConstants.DURATION_BANK[choose]
- silence = GenerationConstants.SILENCE_BANK[choose]
+ choose = [random.randint(0,4) for x in range(4)]
+ density = [GenerationConstants.RYTHM_DENSITY_BANK[i] for i in choose]
+ rytReg = [GenerationConstants.RYTHM_REGU_BANK[i] for i in choose]
+ step = [GenerationConstants.PITCH_STEP_BANK[i] for i in choose]
+ pitReg = [GenerationConstants.PITCH_REGU_BANK[i] for i in choose]
+ dur = [GenerationConstants.DURATION_BANK[i] for i in choose]
+ silence = [GenerationConstants.SILENCE_BANK[i] for i in choose]
pattern = [random.choice([0,1,1,2,3,3]) for x in range(4)]
scale = random.randint(0,6)
return [density, rytReg, step, pitReg, dur, silence, pattern, scale]
@@ -1436,7 +1436,7 @@ class MainWindow( gtk.EventBox ):
except OSError,e:
print 'ERROR: failed to open file %s for writing\n' % ofilename
chooser.destroy()
-
+
def handleLoopSave(self):
date = str(time.localtime()[3]) + '-' + str(time.localtime()[4]) + '-' + str(time.localtime()[5])
ofilename = Config.PREF_DIR + '/' + date + '.ttl'
@@ -1893,7 +1893,7 @@ class InstrumentButton( gtk.DrawingArea ):
| gtk.gdk.BUTTON_RELEASE_MASK
| gtk.gdk.POINTER_MOTION_MASK
| gtk.gdk.POINTER_MOTION_HINT_MASK
- | gtk.gdk.LEAVE_NOTIFY_MASK
+ | gtk.gdk.LEAVE_NOTIFY_MASK
| gtk.gdk.ENTER_NOTIFY_MASK )
self.connect( "size-allocate", self.size_allocate )
self.connect( "button-press-event", self.button_press )
@@ -1987,7 +1987,7 @@ class InstrumentButton( gtk.DrawingArea ):
self.hover = None
if self.clicked == None:
self.queue_draw()
-
+
def setPrimary( self, img ):
self.primary = img
@@ -2044,11 +2044,11 @@ class InstrumentButton( gtk.DrawingArea ):
self.gc.foreground = self.color["+/-"]
self.window.draw_line( self.gc, self.hotspots[0][0], self.hotspots[0][5], self.hotspots[0][2], self.hotspots[0][5] )
self.window.draw_line( self.gc, self.hotspots[0][4], self.hotspots[0][1], self.hotspots[0][4], self.hotspots[0][3] )
-
+
def set_palette(self, palette):
pass
-
-
+
+
class NoneInvoker( Invoker ):
def __init__( self ):
@@ -2060,7 +2060,7 @@ class NoneInvoker( Invoker ):
def get_toplevel( self ):
return None
-
+
class Popup( Palette ):
def __init__( self, label, owner ):
@@ -2074,7 +2074,7 @@ class Popup( Palette ):
self.set_group_id( "TamTamPopup" )
self._set_state( Palette.SECONDARY ) # skip to fully exposed
-
+
self.connect( "key-press-event", self.on_key_press )
self.connect( "key-release-event", self.on_key_release )
@@ -2121,22 +2121,22 @@ class Popup( Palette ):
self.popdown(True)
else:
self.popup( True )
-
+
class instrumentPalette( Popup ):
ICON_SIZE = (70,70)
def __init__(self, label, edit, trackID):
Popup.__init__(self, label, edit)
-
+
self.trackID = trackID
self.edit = edit
-
+
self.tooltips = gtk.Tooltips()
-
+
self.mainBox = gtk.VBox()
self.volumeBox = gtk.HBox()
self.instrumentMainBox = gtk.HBox()
-
+
self.muteButton = gtk.CheckButton()
self.muteButton.connect("toggled",self.edit.handlemuteButton, self.trackID)
self.muteButton.connect("button-press-event",self.edit.handlemuteButtonRightClick, self.trackID)
@@ -2152,9 +2152,9 @@ class instrumentPalette( Popup ):
self.volumeSlider.set_size_request(250, -1)
self.volumeSlider.set_inverted(False)
self.volumeSlider.set_draw_value(False)
-
+
categories = Config.CATEGORIES
-
+
self.categoryBox = BigComboBox()
for category in categories:
image = Config.IMAGE_ROOT + category + '.png'
@@ -2163,12 +2163,12 @@ class instrumentPalette( Popup ):
self.categoryBox.append_item(category, category, icon_name = image, size = instrumentPalette.ICON_SIZE)
self.categoryBox.set_active(0)
self.categoryBox.connect('changed', self.handleCategoryChange)
-
+
self.instrumentBox1 = BigComboBox()
self.instrumentBox1.connect('changed', self.handleInstrumentChange)
self.loadInstrumentMenu(self.getInstruments())
-
-
+
+
self.volumeBox.pack_start(self.muteButton, padding = 5)
self.volumeBox.pack_start(self.volumeSlider, padding = 5)
self.mainBox.pack_start(self.volumeBox, padding = 5)
@@ -2178,17 +2178,17 @@ class instrumentPalette( Popup ):
self.mainBox.show_all()
self.set_content(self.mainBox)
-
+
def handleInstrumentChange(self, widget):
instrument = widget.props.value
self.edit.playInstrumentNote(instrument)
self.edit.donePickInstrument(instrument)
-
+
def handleCategoryChange(self, widget):
category = widget.props.value
instruments = self.getInstruments(category)
self.loadInstrumentMenu(instruments)
-
+
def loadInstrumentMenu(self, instruments):
self.instrumentBox1.remove_all()
for instrument in instruments:
@@ -2197,12 +2197,9 @@ class instrumentPalette( Popup ):
image = Config.IMAGE_ROOT + 'generic.png'
self.instrumentBox1.append_item(instrument, text = None, icon_name = image, size = instrumentPalette.ICON_SIZE)
self.instrumentBox1.set_active(0)
-
+
def getInstruments(self, category = 'all'):
if category == 'all':
return sorted([instrument for instrument in Config.INSTRUMENTS.keys() if not instrument.startswith('drum') and not instrument.startswith('gui')])
else:
return sorted([instrument for instrument in Config.INSTRUMENTS.keys() if not instrument.startswith('drum') and not instrument.startswith('gui') and Config.INSTRUMENTS[instrument].category == category])
-
-
-