Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Generation
diff options
context:
space:
mode:
authorOli <olpc@localhost.localdomain>2007-02-20 04:04:53 (GMT)
committer Oli <olpc@localhost.localdomain>2007-02-20 04:04:53 (GMT)
commited2ba751a970cbbed4d97b3adafe41909d986b0d (patch)
tree7817be57b3a30bc8d862eb477631c601c8680128 /Generation
parent3432315f9f7f67e2469ef6d5c63ae12485ff40c6 (diff)
new generationParametersWindow ( not finish! )
Diffstat (limited to 'Generation')
-rwxr-xr-xGeneration/GenerationConstants.py2
-rwxr-xr-xGeneration/GenerationParametersWindow.py509
-rw-r--r--Generation/GenerationPitch.py2
3 files changed, 413 insertions, 100 deletions
diff --git a/Generation/GenerationConstants.py b/Generation/GenerationConstants.py
index 74b1aec..dbcff25 100755
--- a/Generation/GenerationConstants.py
+++ b/Generation/GenerationConstants.py
@@ -8,7 +8,7 @@ class GenerationConstants:
# Default parameters for algorithmic generation
DEFAULT_DENSITY = 0.7
DEFAULT_RYTHM_REGULARITY = .75
- DEFAULT_STEP = -3
+ DEFAULT_STEP = 0.2
DEFAULT_PITCH_REGULARITY = 0.5
DEFAULT_ARTICULE = 0.7
diff --git a/Generation/GenerationParametersWindow.py b/Generation/GenerationParametersWindow.py
index 5964566..e36c963 100755
--- a/Generation/GenerationParametersWindow.py
+++ b/Generation/GenerationParametersWindow.py
@@ -1,14 +1,27 @@
import pygtk
pygtk.require('2.0')
import gtk
-
+import shelve
from Generation.Generator import GenerationParameters
from Generation.Generator import VariationParameters
from Generation.GenerationConstants import GenerationConstants
+from Util.ThemeWidgets import *
+import Config
class GenerationParametersWindow( gtk.Window ):
def __init__( self, generateFunction, variateFunction, handleCloseWindowCallback ):
gtk.Window.__init__( self, gtk.WINDOW_TOPLEVEL )
+ self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
+ self.set_position( gtk.WIN_POS_CENTER )
+ self.set_default_size(30, 300)
+ self.set_border_width(0)
+ self.set_decorated(False)
+ self.mainBox = RoundVBox(fillcolor="#FFF", bordercolor="#FFF")
+ self.mainBox.set_radius(10)
+
+ self.handleCloseWindowCallback = handleCloseWindowCallback
+ self.connect( "delete_event", handleCloseWindowCallback )
+
self.rythmMethod = GenerationConstants.DEFAULT_RYTHM_METHOD
self.pitchMethod = GenerationConstants.DEFAULT_PITCH_METHOD
self.pattern = GenerationConstants.DEFAULT_PATTERN
@@ -17,134 +30,381 @@ class GenerationParametersWindow( gtk.Window ):
self.rythmVariation = GenerationConstants.DEFAULT_RYTHM_VARIATION
self.generateFunction = generateFunction
self.variateFunction = variateFunction
- self.sourceVariation = 0
- self.setupWindow( handleCloseWindowCallback )
+ self.setupWindow()
- def setupWindow( self, handleCloseWindowCallback ):
- self.set_position( gtk.WIN_POS_CENTER_ON_PARENT )
- self.set_title("Algorithmic generator")
- self.set_border_width(5)
- self.connect( "delete_event", handleCloseWindowCallback )
- self.mainBox = gtk.VBox(False, 5)
- self.generationBox = gtk.VBox(False, 2)
- self.variationBox = gtk.VBox(False, 2)
- self.sliderBox = gtk.VBox(False, 2)
+ def setupWindow( self ):
self.labelRythmMethodBox = gtk.VBox(False, 2)
self.rythmMethodBox = gtk.HBox(False, 2)
- self.labelSourceVariationBox = gtk.VBox(False, 2)
- self.sourceVariationBox = gtk.HBox(False, 2)
self.labelPitchMethodBox = gtk.VBox(False, 2)
self.pitchMethodBox = gtk.HBox(False, 2)
self.labelPatternBox = gtk.VBox(False, 2)
self.patternBox = gtk.HBox(False, 2)
self.labelScaleBox = gtk.VBox(False, 2)
self.scaleBox = gtk.HBox(False, 2)
- self.buttonBox = gtk.HBox(False, 2)
-
- self.labelPitchVariationBox = gtk.VBox(False, 2)
- self.pitchVariationBox = gtk.HBox(False, 2)
- self.labelRythmVariationBox = gtk.VBox(False, 2)
- self.rythmVariationBox = gtk.HBox(False, 2)
-
- self.generationBox.pack_start( gtk.Label( "GENERATION" ), False, False, 0 )
- # Create parameters sliders box
- #TODO: remove magic numbers
- self.densityAdjust = self.initSlider("density", GenerationConstants.DEFAULT_DENSITY, 0, 1, 0.01, 0, 2)
- self.rythmRegularityAdjust = self.initSlider("rythm regularity", GenerationConstants.DEFAULT_RYTHM_REGULARITY, 0, 1, 0.01, 0, 2)
- self.pitchStepAdjust = self.initSlider("pitch max step", GenerationConstants.DEFAULT_STEP, -10, 10, 1, 2, 0)
- self.pitchRegularityAdjust = self.initSlider("pitch regularity", GenerationConstants.DEFAULT_PITCH_REGULARITY, 0, 1, 0.01, 0, 2)
- self.articulationAdjust = self.initSlider("stacato / legato", GenerationConstants.DEFAULT_ARTICULE, 0, 1, 0.01, 0, 2)
- self.generationBox.pack_start(self.sliderBox, 5)
-
- # Create melodic rythm methods box
+
+ self.rythmDensity = GenerationConstants.DEFAULT_DENSITY
+ self.rythmRegularity = GenerationConstants.DEFAULT_RYTHM_REGULARITY
+ self.pitchRegularity = GenerationConstants.DEFAULT_PITCH_REGULARITY
+ self.pitchStep = GenerationConstants.DEFAULT_STEP
+ self.duration = GenerationConstants.DEFAULT_ARTICULE
+ self.silence = .2 #GenerationConstants.DEFAULT_SILENCE
+
+ # Generation Panel Setup
+ generationBox = RoundVBox(fillcolor=Config.INST_BCK_COLOR, bordercolor=Config.PANEL_BCK_COLOR)
+ generationBox.set_border_width(1)
+ generationBox.set_radius(10)
+ XYSlidersBox = gtk.HBox()
+
+ self.col = gtk.gdk.color_parse(Config.PANEL_COLOR)
+
+ XYSlider1Box = gtk.VBox()
+ XYSlider1UpBox = RoundHBox(fillcolor=Config.PANEL_COLOR, bordercolor=Config.INST_BCK_COLOR)
+ XYSlider1UpBox.set_border_width(3)
+ XYSlider1UpBox.set_radius(10)
+ self.XYSlider1DownBox = RoundHBox(fillcolor=Config.PANEL_COLOR, bordercolor=Config.INST_BCK_COLOR)
+ self.XYSlider1DownBox.set_border_width(3)
+ self.XYSlider1DownBox.set_radius(10)
+
+ self.slider1Label = gtk.DrawingArea()
+ self.slider1Label.modify_bg(gtk.STATE_NORMAL, self.col)
+ colormap = self.slider1Label.get_colormap()
+ self.bgColor = colormap.alloc_color( Config.PANEL_COLOR, True, True )
+ self.slider1Label.set_size_request(228, 60)
+ self.slider1Label.connect("expose-event", self.draw )
+ XYSliderBox1 = self.formatRoundBox( RoundFixed(), Config.PANEL_COLOR )
+ XYSliderBox1.set_size_request( 250, 250 )
+ XYButton1 = ImageToggleButton( Config.IMAGE_ROOT+"XYbut.png", Config.IMAGE_ROOT+"XYbutDown.png", backgroundFill=Config.PANEL_COLOR )
+ self.XAdjustment1 = gtk.Adjustment( 100, 0, 200, 1, 1, 1 )
+ self.XAdjustment1.connect("value-changed", self.handleXAdjustment1)
+ self.YAdjustment1 = gtk.Adjustment( 100, 0, 200, 1, 1, 1 )
+ self.YAdjustment1.connect("value-changed", self.handleYAdjustment1)
+ xySlider1 = XYSlider( XYSliderBox1, XYButton1, self.XAdjustment1, self.YAdjustment1, False, True )
+ XYSlider1UpBox.pack_start( xySlider1, False, False )
+
+ self.XYSlider1DownBox.pack_start(self.slider1Label, False, False, 5)
+ XYSlider1Box.pack_start(XYSlider1UpBox)
+ XYSlider1Box.pack_start(self.XYSlider1DownBox)
+ XYSlidersBox.pack_start(XYSlider1Box, False, False, 5)
+
+
+ XYSlider2Box = gtk.VBox()
+ XYSlider2UpBox = RoundHBox(fillcolor=Config.PANEL_COLOR, bordercolor=Config.INST_BCK_COLOR)
+ XYSlider2UpBox.set_border_width(3)
+ XYSlider2UpBox.set_radius(10)
+ self.XYSlider2DownBox = RoundHBox(fillcolor=Config.PANEL_COLOR, bordercolor=Config.INST_BCK_COLOR)
+ self.XYSlider2DownBox.set_border_width(3)
+ self.XYSlider2DownBox.set_radius(10)
+
+ self.slider2Label = gtk.DrawingArea()
+ self.slider2Label.modify_bg(gtk.STATE_NORMAL, self.col)
+ #colormap = self.slider1Label.get_colormap()
+ #self.bgColor = colormap.alloc_color( Config.PANEL_COLOR, True, True )
+ self.slider2Label.set_size_request(228, 60)
+ self.slider2Label.connect("expose-event", self.draw2 )
+ XYSliderBox2 = self.formatRoundBox( RoundFixed(), Config.PANEL_COLOR )
+ XYSliderBox2.set_size_request( 250, 250 )
+ XYButton2 = ImageToggleButton( Config.IMAGE_ROOT+"XYbut.png", Config.IMAGE_ROOT+"XYbutDown.png", backgroundFill=Config.PANEL_COLOR )
+ self.XAdjustment2 = gtk.Adjustment( 100, 0, 200, 1, 1, 1 )
+ self.XAdjustment2.connect("value-changed", self.handleXAdjustment2)
+ self.YAdjustment2 = gtk.Adjustment( 100, 0, 200, 1, 1, 1 )
+ self.YAdjustment2.connect("value-changed", self.handleYAdjustment2)
+ xySlider2 = XYSlider( XYSliderBox2, XYButton2, self.XAdjustment2, self.YAdjustment2, False, True )
+ XYSlider2UpBox.pack_start( xySlider2, False, False )
+
+ self.XYSlider2DownBox.pack_start(self.slider2Label, False, False, 5)
+ XYSlider2Box.pack_start(XYSlider2UpBox)
+ XYSlider2Box.pack_start(self.XYSlider2DownBox)
+ XYSlidersBox.pack_start(XYSlider2Box, False, False, 5)
+
+
+ XYSlider3Box = gtk.VBox()
+ XYSlider3UpBox = RoundHBox(fillcolor=Config.PANEL_COLOR, bordercolor=Config.INST_BCK_COLOR)
+ XYSlider3UpBox.set_border_width(3)
+ XYSlider3UpBox.set_radius(10)
+ self.XYSlider3DownBox = RoundHBox(fillcolor=Config.PANEL_COLOR, bordercolor=Config.INST_BCK_COLOR)
+ self.XYSlider3DownBox.set_border_width(3)
+ self.XYSlider3DownBox.set_radius(10)
+
+ self.slider3Label = gtk.DrawingArea()
+ self.slider3Label.modify_bg(gtk.STATE_NORMAL, self.col)
+ #colormap = self.slider1Label.get_colormap()
+ #self.bgColor = colormap.alloc_color( Config.PANEL_COLOR, True, True )
+ self.slider3Label.set_size_request(228, 60)
+ self.slider3Label.connect("expose-event", self.draw3 )
+ XYSliderBox3 = self.formatRoundBox( RoundFixed(), Config.PANEL_COLOR )
+ XYSliderBox3.set_size_request( 250, 250 )
+ XYButton3 = ImageToggleButton( Config.IMAGE_ROOT+"XYbut.png", Config.IMAGE_ROOT+"XYbutDown.png", backgroundFill=Config.PANEL_COLOR )
+ self.XAdjustment3 = gtk.Adjustment( 100, 0, 200, 1, 1, 1 )
+ self.XAdjustment3.connect("value-changed", self.handleXAdjustment3)
+ self.YAdjustment3 = gtk.Adjustment( 100, 0, 200, 1, 1, 1 )
+ self.YAdjustment3.connect("value-changed", self.handleYAdjustment3)
+ xySlider3 = XYSlider( XYSliderBox3, XYButton3, self.XAdjustment3, self.YAdjustment3, False, True )
+ XYSlider3UpBox.pack_start( xySlider3, False, False )
+
+ self.XYSlider3DownBox.pack_start(self.slider3Label, False, False, 5)
+ XYSlider3Box.pack_start(XYSlider3UpBox)
+ XYSlider3Box.pack_start(self.XYSlider3DownBox)
+ XYSlidersBox.pack_start(XYSlider3Box, False, False, 5)
+
+ generationBox.pack_start(XYSlidersBox, False, False, 5)
+
+ # create cancel/generate button
+ generationButtonBox = gtk.HBox()
+
+ generateButton = ImageButton(Config.IMAGE_ROOT + 'check.png')
+ generateButton.connect("clicked", self.generate)
+
+ genCancelButton = ImageButton(Config.IMAGE_ROOT + 'closeA.png')
+ genCancelButton.connect("clicked", self.cancel)
+
+ # create play/stop buttons
+ genPlayButton = ImageToggleButton(Config.IMAGE_ROOT + 'playTogOff.png', Config.IMAGE_ROOT + 'playTogOn.png')
+ genSelButton = ImageToggleButton(Config.IMAGE_ROOT + 'playAll.png', Config.IMAGE_ROOT + 'playSel.png')
+
+ generationButtonBox.pack_end(generateButton, False, False, 10)
+ generationButtonBox.pack_end(genCancelButton, False, False, 0)
+ generationButtonBox.pack_end(genSelButton, False, False)
+ generationButtonBox.pack_end(genPlayButton, False, False)
+ generationBox.pack_start(generationButtonBox, False, False, 10)
+ self.mainBox.pack_start(generationBox)
+
+
+
+
+
+ # Variation Panel setup
+ variationBox = RoundVBox(fillcolor=Config.INST_BCK_COLOR, bordercolor=Config.PANEL_BCK_COLOR)
+ variationBox.set_border_width(1)
+ variationBox.set_radius(10)
+
+ variationSpacingBox = gtk.VBox()
+
+ COL_LEN = 2
+
+ box = RoundHBox(fillcolor=Config.INST_BCK_COLOR, bordercolor=Config.PANEL_COLOR)
+ imagesName = ['pitchCopy', 'pitchReverse', 'pitchSort', 'pitchShuffle', 'pitchInvert', 'rytCopy', 'rytReverse', 'rytShuffle', 'rytShuffle', 'rytShuffle']
+ imagesNum = len(imagesName)
+ cols = ( imagesNum // COL_LEN )
+ if imagesNum % COL_LEN is not 0: #S'il y a un reste
+ cols = cols + 1
+
+ self.firstButton = None
+ for col in range(cols):
+ vBox = gtk.VBox()
+ for var in range(COL_LEN):
+ hBox = gtk.HBox()
+ index = COL_LEN * col + var
+ img = imagesName[index]
+ iButton = ImageRadioButton(self.firstButton, Config.IMAGE_ROOT + img + '.png', Config.IMAGE_ROOT + img + '.png', Config.IMAGE_ROOT + img + '.png')
+ if self.firstButton == None:
+ self.firstButton = iButton
+ iButton.connect('clicked' , self.handleVariationButton , var)
+ hBox.pack_start(iButton, False, False)
+ vBox.pack_start(hBox, False, False)
+ box.pack_start(vBox, False, False)
+ variationSpacingBox.pack_start(box)
+ variationBox.pack_start(variationSpacingBox, False, False, 5)
+
+ # create cancel/variate button
+ variationButtonBox = gtk.HBox()
+
+ variateButton = ImageButton(Config.IMAGE_ROOT + 'check.png')
+ variateButton.connect("clicked", self.variate)
+
+ varCancelButton = ImageButton(Config.IMAGE_ROOT + 'closeA.png')
+ varCancelButton.connect("clicked", self.cancel)
+
+ # create play/stop buttons
+ varPlayButton = ImageToggleButton(Config.IMAGE_ROOT + 'playTogOff.png', Config.IMAGE_ROOT + 'playTogOn.png')
+ varSelButton = ImageToggleButton(Config.IMAGE_ROOT + 'playAll.png', Config.IMAGE_ROOT + 'playSel.png')
+ variationButtonBox.pack_end(variateButton, False, False, 10)
+ variationButtonBox.pack_end(varCancelButton, False, False)
+ variationButtonBox.pack_end(varSelButton, False, False)
+ variationButtonBox.pack_end(varPlayButton, False, False)
+ variationBox.pack_start(variationButtonBox, False, False, 10)
+ self.mainBox.pack_start(variationBox)
+
+
+
+ # Meta Algo Panel Setup
+ metaAlgoBox = RoundVBox(fillcolor=Config.INST_BCK_COLOR, bordercolor=Config.PANEL_BCK_COLOR)
+ metaAlgoBox.set_border_width(1)
+ metaAlgoBox.set_radius(10)
+
+ # Create save/load presets
+ metaButtonBox = RoundHBox(fillcolor=Config.INST_BCK_COLOR, bordercolor=Config.PANEL_BCK_COLOR)
+ metaButtonBox.set_radius(10)
+
+ saveButton = ImageButton(Config.TAM_TAM_ROOT + '/Resources/Images/save.png')
+ saveButton.connect("clicked", self.handleSave, None)
+ metaButtonBox.pack_start(saveButton, False, False, 2)
+
+ loadButton = ImageButton(Config.TAM_TAM_ROOT + '/Resources/Images/load.png')
+ loadButton.connect("clicked", self.handleLoad, None)
+ metaButtonBox.pack_start(loadButton, False, False, 2)
+
+ metaAlgoBox.pack_start(metaButtonBox)
+
+ # create cancel/variate button
+ metaButton = ImageButton(Config.IMAGE_ROOT + 'check.png')
+ metaButton.connect("clicked", self.variate)
+
+ metaCancelButton = ImageButton(Config.IMAGE_ROOT + 'closeA.png')
+ metaCancelButton.connect("clicked", self.cancel)
+
+ # create play/stop buttons
+ metaPlayButton = ImageToggleButton(Config.IMAGE_ROOT + 'playTogOff.png', Config.IMAGE_ROOT + 'playTogOn.png')
+ metaSelButton = ImageToggleButton(Config.IMAGE_ROOT + 'playAll.png', Config.IMAGE_ROOT + 'playSel.png')
+ metaButtonBox.pack_end(metaButton, False, False, 10)
+ metaButtonBox.pack_end(metaCancelButton, False, False)
+ metaButtonBox.pack_end(metaSelButton, False, False)
+ metaButtonBox.pack_end(metaPlayButton, False, False)
+ metaAlgoBox.pack_start(metaButtonBox, False, False, 10)
+
+
+ # Create melodic rythm methods box
self.labelRythmMethodBox.pack_start(gtk.Label("melodic rythm generation method"), False, False, 0)
- self.generationBox.pack_start(self.labelRythmMethodBox, 3)
+ #metaAlgoBox.pack_start(self.labelRythmMethodBox, 3)
rythmMethodType = ['Cellule', 'Xnoise' ]
self.initRadioButton( rythmMethodType, self.rythmMethodCallback, self.rythmMethodBox )
- self.generationBox.pack_start(self.rythmMethodBox, 3)
+ #metaAlgoBox.pack_start(self.rythmMethodBox, 3)
# Create pitch generation methods box
self.labelPitchMethodBox.pack_start(gtk.Label("pitch generation method"), False, False, 0)
- self.generationBox.pack_start(self.labelPitchMethodBox, 3)
+ #metaAlgoBox.pack_start(self.labelPitchMethodBox, 3)
pitchMethodType = [ 'melodic', 'harmonic' ]
self.initRadioButton( pitchMethodType, self.pitchMethodCallback, self.pitchMethodBox )
- self.generationBox.pack_start(self.pitchMethodBox, 3)
+ #metaAlgoBox.pack_start(self.pitchMethodBox, 3)
# Create pitch patterns box
self.labelPatternBox.pack_start(gtk.Label("pitch pattern"), False, False, 0)
- self.generationBox.pack_start(self.labelPatternBox, 3)
+ #metaAlgoBox.pack_start(self.labelPatternBox, 3)
patternType = [ 'Drunk', 'DroneJump', 'Repeter', 'Loopseg' ]
self.initRadioButton( patternType, self.patternCallback, self.patternBox )
- self.generationBox.pack_start(self.patternBox, 3)
+ #metaAlgoBox.pack_start(self.patternBox, 3)
# Create scales box
self.labelScaleBox.pack_start(gtk.Label("scales"), False, False, 0)
- self.generationBox.pack_start(self.labelScaleBox, 3)
+ #metaAlgoBox.pack_start(self.labelScaleBox, 3)
scalesType = [ 'Major', 'Minor H', 'Minor N', 'Phrygien' ]
self.initRadioButton( scalesType, self.scaleCallback, self.scaleBox )
- self.generationBox.pack_start(self.scaleBox, 3)
+ #metaAlgoBox.pack_start(self.scaleBox, 3)
- # create generate button
- generateButton = gtk.Button('Generate')
- generateButton.connect("clicked", self.generate)
- self.buttonBox.pack_start(generateButton)
- self.generationBox.pack_start(self.buttonBox, 3)
-
- # create variation box
- self.variationBox.pack_start( gtk.Label( "VARIATION" ), False, False, 0 )
-
- # create source variation box
- self.labelSourceVariationBox.pack_start(gtk.Label("pages sources"), False, False, 0)
- self.variationBox.pack_start(self.labelSourceVariationBox, 3)
- sourceVariationType = [ 1, 2, 3, 4, 5 ]
- self.initSourceRadioButton( sourceVariationType, self.sourceVariationCallback, self.sourceVariationBox )
- self.variationBox.pack_start(self.sourceVariationBox, 3)
-
- # create pitch variation box
- self.labelPitchVariationBox.pack_start(gtk.Label("pitch variation"), False, False, 0)
- self.variationBox.pack_start(self.labelPitchVariationBox, 3)
- pitchVariationType = [ 'Copy', 'Markov', 'Reverse', 'Sort', 'Shuffle' ]
- self.initRadioButton( pitchVariationType, self.pitchVariationCallback, self.pitchVariationBox )
- self.variationBox.pack_start(self.pitchVariationBox, 3)
-
- # create rythm variation box
- self.labelRythmVariationBox.pack_start(gtk.Label("rythm variation"), False, False, 0)
- self.variationBox.pack_start(self.labelRythmVariationBox, 3)
- rythmVariationType = [ 'Copy', 'Reverse', 'Shuffle' ]
- self.initRadioButton( rythmVariationType, self.rythmVariationCallback, self.rythmVariationBox )
- self.variationBox.pack_start(self.rythmVariationBox, 3)
-
- # create variate button
- variateButton = gtk.Button('Variate')
- variateButton.connect("clicked", self.variate)
- self.variationBox.pack_start(variateButton, 3)
+ self.mainBox.pack_start(metaAlgoBox)
+ self.add(self.mainBox)
+ self.loadPixmaps()
+
+ def loadPixmaps( self ):
+ win = gtk.gdk.get_default_root_window()
+ self.gc = gtk.gdk.GC( win )
+ self.gc.foreground = self.bgColor
+
+ self.arrowPixmap = []
+ for i in range(2):
+ pix = gtk.gdk.pixbuf_new_from_file(Config.IMAGE_ROOT + ['arrowSide.png', 'arrowUp.png'][i])
+ map = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ map.draw_rectangle( self.gc, True, 0, 0, pix.get_width(), pix.get_height() )
+ map.draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
+ self.arrowPixmap.append(map)
+
+ self.rythDensPixmap = []
+ self.rythRegPixmap = []
+ self.pitchRegPixmap = []
+ self.pitchStepPixmap = []
+ self.durPixmap = []
+ self.silencePixmap = []
+ pixmaps = [self.rythDensPixmap, self.rythRegPixmap, self.pitchRegPixmap, self.pitchStepPixmap, self.durPixmap, self.silencePixmap]
+ pixmapNames = ['rythDens', 'rythReg', 'pitReg', 'pitStep', 'durLen', 'durDens']
+
+ for inc in range(6):
+ imgName = pixmapNames[inc]
+ pixmap = pixmaps[inc]
+ for i in range(6):
+ pix = gtk.gdk.pixbuf_new_from_file(Config.IMAGE_ROOT + imgName + str(i+1) + '.png')
+ map = gtk.gdk.Pixmap( win, pix.get_width(), pix.get_height() )
+ map.draw_rectangle( self.gc, True, 0, 0, pix.get_width(), pix.get_height() )
+ map.draw_pixbuf( self.gc, pix, 0, 0, 0, 0, pix.get_width(), pix.get_height(), gtk.gdk.RGB_DITHER_NONE )
+ pixmap.append(map)
+
+
+ def draw( self, widget, event ):
+ imgX = 5 - int(self.rythmDensity * 5)
+ imgY = 5 - int(self.rythmRegularity * 5)
+ widget.window.draw_drawable( self.gc, self.arrowPixmap[0], 0, 0, 0, 18, 24, 24 )
+ widget.window.draw_drawable( self.gc, self.rythDensPixmap[imgX], 0, 0, 24, 0, 90, 60 )
+ widget.window.draw_drawable( self.gc, self.arrowPixmap[1], 0, 0, 114, 18, 24, 24 )
+ widget.window.draw_drawable( self.gc, self.rythRegPixmap[imgY], 0, 0, 138, 0, 90, 60 )
+ return True
+
+ def draw2( self, widget, event ):
+ imgX = 5 - int(self.pitchRegularity * 5)
+ imgY = 5 - int(self.pitchStep * 5)
+ widget.window.draw_drawable( self.gc, self.arrowPixmap[0], 0, 0, 0, 18, 24, 24 )
+ widget.window.draw_drawable( self.gc, self.pitchRegPixmap[imgX], 0, 0, 24, 0, 90, 60 )
+ widget.window.draw_drawable( self.gc, self.arrowPixmap[1], 0, 0, 114, 18, 24, 24 )
+ widget.window.draw_drawable( self.gc, self.pitchStepPixmap[imgY], 0, 0, 138, 0, 90, 60 )
+ return True
+
+ def draw3( self, widget, event ):
+ imgX = int(self.duration * 5)
+ imgY = int(self.silence * 5)
+ widget.window.draw_drawable( self.gc, self.arrowPixmap[0], 0, 0, 0, 18, 24, 24 )
+ widget.window.draw_drawable( self.gc, self.durPixmap[imgX], 0, 0, 24, 0, 90, 60 )
+ widget.window.draw_drawable( self.gc, self.arrowPixmap[1], 0, 0, 114, 18, 24, 24 )
+ widget.window.draw_drawable( self.gc, self.silencePixmap[imgY], 0, 0, 138, 0, 90, 60 )
+ return True
+
+
+
+
+ def handleXAdjustment1( self, data ):
+ self.rythmDensity = self.XAdjustment1.value / 200
+ self.slider1Label.queue_draw()
- self.mainBox.pack_start(self.generationBox)
- self.mainBox.pack_start(self.variationBox)
+ def handleYAdjustment1( self, data ):
+ self.rythmRegularity = self.YAdjustment1.value / 200
+ self.slider1Label.queue_draw()
+
+ def handleXAdjustment2( self, data ):
+ self.pitchRegularity = self.XAdjustment2.value / 200
+ self.slider2Label.queue_draw()
+
+ def handleYAdjustment2( self, data ):
+ self.pitchStep = self.YAdjustment2.value / 200
+ self.slider2Label.queue_draw()
+
+ def handleXAdjustment3( self, data ):
+ self.duration = self.XAdjustment3.value / 200
+ self.slider3Label.queue_draw()
+
+ def handleYAdjustment3( self, data ):
+ self.silence = self.YAdjustment3.value / 200
+ self.slider3Label.queue_draw()
- self.add(self.mainBox)
def getGenerationParameters( self ):
- return GenerationParameters( self.densityAdjust.value,
- self.rythmRegularityAdjust.value,
- self.pitchStepAdjust.value,
- self.pitchRegularityAdjust.value,
- self.articulationAdjust.value,
+ return GenerationParameters( self.rythmDensity,
+ self.rythmRegularity,
+ self.pitchStep,
+ self.pitchRegularity,
+ self.duration,
self.rythmMethod,
self.pitchMethod,
self.pattern,
self.scale )
- def generate(self, data=None):
+ def cancel( self, widget, data=None ):
+ self.handleCloseWindowCallback()
+
+ def generate(self, widget, data=None):
self.generateFunction( self.getGenerationParameters() )
- def getVariationParameters( self ):
- return VariationParameters( self.sourceVariation,
- self.pitchVariation,
- self.rythmVariation )
- def variate( self, data=None ):
- self.variateFunction( self.getVariationParameters() )
+ def handleVariationButton( self, widget, var ):
+ pass
+
+ def variate( self, widget, data ):
+ pass
def rythmMethodCallback( self, widget, rythmMethod ):
if widget.get_active():
@@ -162,17 +422,70 @@ class GenerationParametersWindow( gtk.Window ):
if widget.get_active():
self.scale = scale
- def sourceVariationCallback( self, widget, data ):
- if widget.get_active():
- self.sourceVariation = int( data )
+ def formatRoundBox( self, box, fillcolor ):
+ box.set_radius( 10 )
+ box.set_border_width( 1 )
+ box.set_fill_color( fillcolor )
+ box.set_border_color( Config.INST_BCK_COLOR )
+ return box
- def pitchVariationCallback( self, widget, data ):
- if widget.get_active():
- self.pitchVariation = data
- def rythmVariationCallback( self, widget, data ):
- if widget.get_active():
- self.rythmVariation = data
+#=========================== PRESETS ================================
+
+ def handleSave(self, widget, data):
+ chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK))
+
+ if chooser.run() == gtk.RESPONSE_OK:
+ try:
+ print 'INFO: save preset file %s' % chooser.get_filename()
+ f = shelve.open( chooser.get_filename(), 'n')
+ self.saveState(f)
+ f.close()
+ except IOError:
+ print 'ERROR: failed to save preset to file %s' % chooser.get_filename()
+
+ chooser.destroy()
+
+ def handleLoad(self, widget, data):
+
+ chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
+
+ if chooser.run() == gtk.RESPONSE_OK:
+ try:
+ print 'INFO: load preset state from file %s' % chooser.get_filename()
+ f = shelve.open( chooser.get_filename(), 'r')
+ self.loadState(f)
+ f.close()
+ except IOError:
+ print 'ERROR: failed to load preset state from file %s' % chooser.get_filename()
+
+ def loadState( self, state ):
+ pass
+ self.rythmDensity = state['rythmDensity']
+ self.rythmRegularity = state['rythmRegularity']
+ self.pitchRegularity = state['pitchRegularity']
+ self.pitchStep = state['pitchStep']
+ self.duration = state['duration']
+ self.silence = state['silence']
+
+ self.XAdjustment1.set_value(self.rythmDensity*200)
+ self.YAdjustment1.set_value(self.rythmRegularity*200)
+ self.XAdjustment2.set_value(self.pitchRegularity*200)
+ self.YAdjustment2.set_value(self.pitchStep*200)
+ self.XAdjustment3.set_value(self.duration*200)
+ self.YAdjustment3.set_value(self.silence*200)
+
+ def saveState( self, state ):
+ pass
+ state['rythmDensity'] = self.rythmDensity
+ state['rythmRegularity'] = self.rythmRegularity
+ state['pitchRegularity'] = self.pitchRegularity
+ state['pitchStep'] = self.pitchStep
+ state['duration'] = self.duration
+ state['silence'] = self.silence
+
+
+#=================================================================================
def initSlider(self, label, initValue, minValue, maxValue, incStep, policy, digits):
sliderAdjust = gtk.Adjustment(initValue, minValue, maxValue, incStep, incStep, 0)
diff --git a/Generation/GenerationPitch.py b/Generation/GenerationPitch.py
index bc38ee1..4ce9578 100644
--- a/Generation/GenerationPitch.py
+++ b/Generation/GenerationPitch.py
@@ -34,7 +34,7 @@ class GenerationPitch:
pitchSequence = []
numberOfPitch = int( ( 1 - parameters.pitchRegularity ) * 10 + 1 )
for i in range(numberOfPitch):
- pitchSequence.append((table_pitch[pitchMethod.getNextValue(parameters.step, (len(table_pitch)-1))]) + GenerationConstants.DEFAULT_TONIQUE)
+ pitchSequence.append((table_pitch[pitchMethod.getNextValue(10 - (int(parameters.step * 10)), (len(table_pitch)-1))]) + GenerationConstants.DEFAULT_TONIQUE)
for i in range( length - numberOfPitch ):
position = i % numberOfPitch
pitchSequence.append( pitchSequence[ position ] )