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-26 23:43:01 (GMT)
committer Oli <olpc@localhost.localdomain>2007-02-26 23:43:01 (GMT)
commit23cbcc5c48f82630055e553e6c098a40fdb96f6a (patch)
tree48842192b8c34cd9a11d4c1219bfa6b408c96c0d /Generation
parent737bd549d0bdd42fce9b8860c1c855ff7233a143 (diff)
parameter silence ( generation ) is active
Diffstat (limited to 'Generation')
-rwxr-xr-xGeneration/GenerationConstants.py5
-rwxr-xr-xGeneration/GenerationParametersWindow.py93
-rwxr-xr-xGeneration/Generator.py5
3 files changed, 12 insertions, 91 deletions
diff --git a/Generation/GenerationConstants.py b/Generation/GenerationConstants.py
index 56e815b..a014ba4 100755
--- a/Generation/GenerationConstants.py
+++ b/Generation/GenerationConstants.py
@@ -11,6 +11,7 @@ class GenerationConstants:
DEFAULT_STEP = 0.2
DEFAULT_PITCH_REGULARITY = 0.5
DEFAULT_ARTICULE = 0.7
+ DEFAULT_SILENCE = 0.2
DEFAULT_RYTHM_METHOD = 0
DEFAULT_PITCH_METHOD = 0
@@ -18,8 +19,8 @@ class GenerationConstants:
DEFAULT_PATTERN = 0
- DEFAULT_PITCH_VARIATION = 0
- DEFAULT_RYTHM_VARIATION = 0
+ DEFAULT_PITCH_VARIATION = 0 # 0 = 'melodic' 1 = 'harmonic'
+ DEFAULT_RYTHM_VARIATION = 0 # 0 = 'Cellule' 1 = 'Xnoise'
TABLE_ONSET_VALUES = [ 3, 4, 6, 8, 12, 18, 24, 36, 48 ]
diff --git a/Generation/GenerationParametersWindow.py b/Generation/GenerationParametersWindow.py
index d2cae6c..dddc5da 100755
--- a/Generation/GenerationParametersWindow.py
+++ b/Generation/GenerationParametersWindow.py
@@ -151,9 +151,6 @@ class GenerationParametersWindow( gtk.Window ):
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)
@@ -198,7 +195,6 @@ class GenerationParametersWindow( gtk.Window ):
sourceImg.set_from_file(Config.IMAGE_ROOT + 'source.png')
varRytBox.pack_end(sourceImg, False, False)
-
variationSpacingBox.pack_start(varPitchBox)
variationSpacingBox.pack_start(varRytBox)
variationBox.pack_start(variationSpacingBox, False, False, 5)
@@ -231,39 +227,8 @@ class GenerationParametersWindow( gtk.Window ):
scaleBox.pack_start(iButton, False, False)
metaAlgoBox.pack_start(scaleBox, False, False)
-
-
self.mainBox.pack_start(metaAlgoBox)
- # Create melodic rythm methods box
- self.labelRythmMethodBox.pack_start(gtk.Label("melodic rythm generation method"), False, False, 0)
- #metaAlgoBox.pack_start(self.labelRythmMethodBox, 3)
- rythmMethodType = ['Cellule', 'Xnoise' ]
- self.initRadioButton( rythmMethodType, self.rythmMethodCallback, self.rythmMethodBox )
- #metaAlgoBox.pack_start(self.rythmMethodBox, 3)
-
- # Create pitch generation methods box
- self.labelPitchMethodBox.pack_start(gtk.Label("pitch generation method"), False, False, 0)
- #metaAlgoBox.pack_start(self.labelPitchMethodBox, 3)
- pitchMethodType = [ 'melodic', 'harmonic' ]
- self.initRadioButton( pitchMethodType, self.pitchMethodCallback, self.pitchMethodBox )
- #metaAlgoBox.pack_start(self.pitchMethodBox, 3)
-
- # Create pitch patterns box
- self.labelPatternBox.pack_start(gtk.Label("pitch pattern"), False, False, 0)
- #metaAlgoBox.pack_start(self.labelPatternBox, 3)
- patternType = [ 'Drunk', 'DroneJump', 'Repeter', 'Loopseg' ]
- self.initRadioButton( patternType, self.patternCallback, self.patternBox )
- #metaAlgoBox.pack_start(self.patternBox, 3)
-
- # Create scales box
- self.labelScaleBox.pack_start(gtk.Label("scales"), False, False, 0)
- #metaAlgoBox.pack_start(self.labelScaleBox, 3)
- scalesType = [ 'Major', 'Minor H', 'Minor N', 'Phrygien' ]
- self.initRadioButton( scalesType, self.scaleCallback, self.scaleBox )
- #metaAlgoBox.pack_start(self.scaleBox, 3)
-
-
# Transport Panel Setup
transportBox = RoundVBox(fillcolor=Config.INST_BCK_COLOR, bordercolor=Config.PANEL_BCK_COLOR)
transportBox.set_border_width(1)
@@ -299,7 +264,6 @@ class GenerationParametersWindow( gtk.Window ):
transButtonBox.pack_end(playButton, False, False)
transportBox.pack_start(transButtonBox, False, False, 10)
-
self.mainBox.pack_start(transportBox)
self.add(self.mainBox)
self.loadPixmaps()
@@ -365,8 +329,6 @@ class GenerationParametersWindow( gtk.Window ):
return True
-
-
def handleXAdjustment1( self, data ):
self.rythmDensity = self.XAdjustment1.value / 200
self.slider1Label.queue_draw()
@@ -398,6 +360,7 @@ class GenerationParametersWindow( gtk.Window ):
self.pitchStep,
self.pitchRegularity,
self.duration,
+ self.silence,
self.rythmMethod,
self.pitchMethod,
self.pattern,
@@ -436,22 +399,6 @@ class GenerationParametersWindow( gtk.Window ):
if widget.get_active():
self.scale = scale
- def rythmMethodCallback( self, widget, rythmMethod ):
- if widget.get_active():
- self.rythmMethod = rythmMethod
-
- def pitchMethodCallback( self, widget, pitchMethod ):
- if widget.get_active():
- self.pitchMethod = pitchMethod
-
- def scaleCallback( self, widget, scale ):
- pass
-# if widget.get_active():
-# self.scale = scale
-
- def patternCallback( self, widget, data ):
- pass
-
def formatRoundBox( self, box, fillcolor ):
box.set_radius( 10 )
box.set_border_width( 1 )
@@ -497,6 +444,8 @@ class GenerationParametersWindow( gtk.Window ):
self.pitchStep = state['pitchStep']
self.duration = state['duration']
self.silence = state['silence']
+ self.pattern = state['pattern']
+ self.scale = state['scale']
self.XAdjustment1.set_value(self.rythmDensity*200)
self.YAdjustment1.set_value(self.rythmRegularity*200)
@@ -513,37 +462,5 @@ class GenerationParametersWindow( gtk.Window ):
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)
- slider = gtk.HScale(sliderAdjust)
- slider.set_update_policy(policy)
- slider.set_digits(digits)
- slider.set_value_pos(1)
- slider.set_size_request(250, 25)
- self.sliderBox.pack_start(gtk.Label(label), False, False, 0)
- self.sliderBox.pack_start(slider)
- return sliderAdjust
-
- def initRadioButton( self, labelList, methodCallback, box ):
- for i in range( len( labelList ) ):
- if i == 0:
- button = gtk.RadioButton( None, labelList[ i ] )
- else:
- button = gtk.RadioButton( button, labelList[ i ] )
- button.connect( "toggled", methodCallback, i )
- box.pack_start( button, True, True, 0 )
-
- def initSourceRadioButton( self, labelList, methodCallback, box ):
- for i in range( len( labelList ) ):
- if i == 0:
- button = gtk.RadioButton(None, str( labelList[ i ] ) )
- else:
- button = gtk.RadioButton( button, str( labelList[ i ] ) )
- button.connect( "toggled", methodCallback, i )
- box.pack_start( button, True, True, 0 )
- if i == 0:
- button.set_active(True)
+ state['pattern'] = self.pattern
+ state['scale'] = self.scale
diff --git a/Generation/Generator.py b/Generation/Generator.py
index 7012bdc..0f76100 100755
--- a/Generation/Generator.py
+++ b/Generation/Generator.py
@@ -19,6 +19,7 @@ class GenerationParameters:
step = GenerationConstants.DEFAULT_STEP,
pitchRegularity = GenerationConstants.DEFAULT_PITCH_REGULARITY,
articule = GenerationConstants.DEFAULT_ARTICULE,
+ silence = GenerationConstants.DEFAULT_SILENCE,
rythmMethod = GenerationConstants.DEFAULT_RYTHM_METHOD,
pitchMethod = GenerationConstants.DEFAULT_PITCH_METHOD,
pattern = GenerationConstants.DEFAULT_PATTERN,
@@ -28,6 +29,7 @@ class GenerationParameters:
self.step = step
self.pitchRegularity = pitchRegularity
self.articule = articule
+ self.silence = silence
self.rythmMethod = rythmMethod
self.pitchMethod = pitchMethod
self.pattern = pattern
@@ -128,7 +130,8 @@ def generator1(
durationSequence, fullDurationSequence = makeDurationSequence(rythmSequence, parameters, table_duration, barLength, currentInstrument)
for i in range(len(rythmSequence)):
- trackNotes.append( CSoundNote( rythmSequence[i], pitchSequence[i], gainSequence[i],
+ if random.random() > parameters.silence:
+ trackNotes.append( CSoundNote( rythmSequence[i], pitchSequence[i], gainSequence[i],
GenerationConstants.DEFAULT_PAN, durationSequence[i], trackId,
fullDurationSequence[i], instrument[ trackId ] ) )
# del trackDictionary[ trackId ][ pageId ]