Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
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
parent05958007515277d0adcd9ae161c12ddb0cfb6426 (diff)
meta algo
-rw-r--r--TamTamEdit.activity/Edit/EditToolbars.py41
-rw-r--r--TamTamEdit.activity/Edit/MainWindow.py67
-rw-r--r--TamTamJam.activity/Jam/Popup.py68
-rwxr-xr-xcommon/Generation/GenerationConstants.py12
-rw-r--r--common/Generation/GenerationPitch.py4
-rw-r--r--common/Generation/GenerationRythm.py14
-rwxr-xr-xcommon/Generation/Generator.py17
7 files changed, 112 insertions, 111 deletions
diff --git a/TamTamEdit.activity/Edit/EditToolbars.py b/TamTamEdit.activity/Edit/EditToolbars.py
index ae0c334..1335180 100644
--- a/TamTamEdit.activity/Edit/EditToolbars.py
+++ b/TamTamEdit.activity/Edit/EditToolbars.py
@@ -41,7 +41,7 @@ class mainToolbar(gtk.Toolbar):
self.toolbox = toolbox
self.edit = edit
-
+
self.tooltips = gtk.Tooltips()
#Play button
@@ -196,16 +196,16 @@ class generateToolbar(gtk.Toolbar):
self.pauseButtonImg = gtk.Image()
self.pauseButtonImg.set_from_icon_name('media-playback-pause', gtk.ICON_SIZE_LARGE_TOOLBAR)
self.pauseButtonImg.show()
-
+
_insertSeparator(1)
-
+
#BigGeneration button
self.bigGenerationButton = ToolButton('diceB')
self.bigGenerationButton.connect('clicked', self.edit.createNewTune)
self.insert(self.bigGenerationButton, -1)
self.bigGenerationButton.show()
self.bigGenerationButton.set_tooltip(_('Generate Tune'))
-
+
#Generation button
self._generationPalette = generationPalette(_('Generation'), self.edit)
self.generationButton = ToggleToolButton('dice')
@@ -220,7 +220,7 @@ class generateToolbar(gtk.Toolbar):
self.propsButton.set_palette(self._propertiesPalette)
self.insert(self.propsButton, -1)
self.propsButton.show()
-
+
def handlePlayPause(self, widget, data = None):
if widget.get_active():
self.edit.handlePlay(widget)
@@ -444,9 +444,9 @@ class generationPalette(Palette):
self.XYSliderBox1 = RoundFixed(fillcolor = '#CCCCCC', bordercolor = '#000000')
self.XYSliderBox1.set_size_request(200,200)
self.XYButton1 = ImageToggleButton( Config.TAM_TAM_ROOT + '/icons/XYBut.svg', Config.TAM_TAM_ROOT + '/icons/XYButDown.svg')
- self.XAdjustment1 = gtk.Adjustment(self.rythmDensity * 100, 0, 100, 1, 1, 1)
+ self.XAdjustment1 = gtk.Adjustment(self.rythmDensity[0] * 100, 0, 100, 1, 1, 1)
self.XAdjustment1.connect("value-changed", self.handleXAdjustment1)
- self.YAdjustment1 = gtk.Adjustment(self.rythmRegularity * 100, 0, 100, 1, 1, 1)
+ self.YAdjustment1 = gtk.Adjustment(self.rythmRegularity[0] * 100, 0, 100, 1, 1, 1)
self.YAdjustment1.connect("value-changed", self.handleYAdjustment1)
self.XYSlider1 = XYSlider( self.XYSliderBox1, self.XYButton1, self.XAdjustment1, self.YAdjustment1, False, True )
self.XSlider1BottomLabelBox.pack_start(self.XSlider1Img, False, False, padding = 5)
@@ -471,9 +471,9 @@ class generationPalette(Palette):
self.XYSliderBox2 = RoundFixed(fillcolor = '#CCCCCC', bordercolor = '#000000')
self.XYSliderBox2.set_size_request(200,200)
self.XYButton2 = ImageToggleButton( Config.TAM_TAM_ROOT + '/icons/XYBut.svg', Config.TAM_TAM_ROOT + '/icons/XYButDown.svg')
- self.XAdjustment2 = gtk.Adjustment(self.pitchRegularity * 100, 0, 100, 1, 1, 1)
+ self.XAdjustment2 = gtk.Adjustment(self.pitchRegularity[0] * 100, 0, 100, 1, 1, 1)
self.XAdjustment2.connect("value-changed", self.handleXAdjustment2)
- self.YAdjustment2 = gtk.Adjustment(self.pitchStep * 100, 0, 100, 1, 1, 1)
+ self.YAdjustment2 = gtk.Adjustment(self.pitchStep[0] * 100, 0, 100, 1, 1, 1)
self.YAdjustment2.connect("value-changed", self.handleYAdjustment2)
self.XYSlider2 = XYSlider( self.XYSliderBox2, self.XYButton2, self.XAdjustment2, self.YAdjustment2, False, True )
self.XSlider2BottomLabelBox.pack_start(self.XSlider2Img, False, False, padding = 5)
@@ -498,9 +498,9 @@ class generationPalette(Palette):
self.XYSliderBox3 = RoundFixed(fillcolor = '#CCCCCC', bordercolor = '#000000')
self.XYSliderBox3.set_size_request(200,200)
self.XYButton3 = ImageToggleButton( Config.TAM_TAM_ROOT + '/icons/XYBut.svg', Config.TAM_TAM_ROOT + '/icons/XYButDown.svg')
- self.XAdjustment3 = gtk.Adjustment(self.duration * 100, 0, 100, 1, 1, 1)
+ self.XAdjustment3 = gtk.Adjustment(self.duration[0] * 100, 0, 100, 1, 1, 1)
self.XAdjustment3.connect("value-changed", self.handleXAdjustment3)
- self.YAdjustment3 = gtk.Adjustment(self.silence * 100, 0, 100, 1, 1, 1)
+ self.YAdjustment3 = gtk.Adjustment(self.silence[0] * 100, 0, 100, 1, 1, 1)
self.YAdjustment3.connect("value-changed", self.handleYAdjustment3)
self.XYSlider3 = XYSlider( self.XYSliderBox3, self.XYButton3, self.XAdjustment3, self.YAdjustment3, False, True )
self.XSlider3BottomLabelBox.pack_start(self.XSlider3Img, False, False, padding = 5)
@@ -610,27 +610,28 @@ class generationPalette(Palette):
def handleXAdjustment1( self, data ):
- self.rythmDensity = self.XAdjustment1.value * .01
+ self.rythmDensity = [self.XAdjustment1.value * .01 for x in range(4)]
+
self.parametersChanged()
def handleYAdjustment1( self, data ):
- self.rythmRegularity = self.YAdjustment1.value * .01
+ self.rythmRegularity = [self.YAdjustment1.value * .01 for x in range(4)]
self.parametersChanged()
def handleXAdjustment2( self, data ):
- self.pitchRegularity = self.XAdjustment2.value * .01
+ self.pitchRegularity = [self.XAdjustment2.value * .01 for x in range(4)]
self.parametersChanged()
def handleYAdjustment2( self, data ):
- self.pitchStep = self.YAdjustment2.value * .01
+ self.pitchStep = [self.YAdjustment2.value * .01 for x in range(4)]
self.parametersChanged()
def handleXAdjustment3( self, data ):
- self.duration = self.XAdjustment3.value * .01
+ self.duration = [self.XAdjustment3.value * .01 for x in range(4)]
self.parametersChanged()
def handleYAdjustment3( self, data ):
- self.silence = self.YAdjustment3.value * .01
+ self.silence = [self.YAdjustment3.value * .01 for x in range(4)]
self.parametersChanged()
def handleScale(self, widget, data = None):
@@ -674,19 +675,19 @@ class generationPalette(Palette):
def previewGenerator(self, parameters):
makeRythm = GenerationRythm()
makePitch = GenerationPitch()
- table_duration = Utils.scale(parameters.articule, GenerationConstants.ARTICULATION_SCALE_MIN_MAPPING, GenerationConstants.ARTICULATION_SCALE_MAX_MAPPING, GenerationConstants.ARTICULATION_SCALE_STEPS)
+ table_duration = Utils.scale(parameters.articule[0], GenerationConstants.ARTICULATION_SCALE_MIN_MAPPING, GenerationConstants.ARTICULATION_SCALE_MAX_MAPPING, GenerationConstants.ARTICULATION_SCALE_STEPS)
table_pitch = GenerationConstants.SCALES[parameters.scale]
beat = self.edit.noteDB.pages[self.edit.tuneInterface.getSelectedIds()[0]].beats
barLength = Config.TICKS_PER_BEAT * beat
trackNotes = []
- rythmSequence = makeRythm.celluleRythmSequence(parameters, barLength)
+ rythmSequence = makeRythm.celluleRythmSequence(parameters, barLength, 0)
pitchSequence = makePitch.drunkPitchSequence(len(rythmSequence),parameters, table_pitch, 0)
gainSequence = self.makeGainSequence(rythmSequence)
durationSequence = self.makeDurationSequence(rythmSequence, parameters, table_duration, barLength)
for i in range(len(rythmSequence)):
- if random() > parameters.silence:
+ if random() > parameters.silence[0]:
trackNotes.append([rythmSequence[i], pitchSequence[i], gainSequence[i], durationSequence[i]])
#print "-------------------------------------------------------",trackNotes
return ( trackNotes, beat )
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])
-
-
-
diff --git a/TamTamJam.activity/Jam/Popup.py b/TamTamJam.activity/Jam/Popup.py
index bcc2504..bbc6bd8 100644
--- a/TamTamJam.activity/Jam/Popup.py
+++ b/TamTamJam.activity/Jam/Popup.py
@@ -51,7 +51,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 )
@@ -100,11 +100,11 @@ class Popup( Palette ):
class Instrument( Popup ):
-
+
def __init__( self, label, owner ):
Popup.__init__( self, label, owner )
- self.settingBlock = False
+ self.settingBlock = False
self.GUI = {}
@@ -205,7 +205,7 @@ class Instrument( Popup ):
class Drum( Popup ):
-
+
def __init__( self, label, owner ):
Popup.__init__( self, label, owner )
@@ -232,7 +232,7 @@ class Drum( Popup ):
self.GUI["volumeBox"].pack_start( self.GUI["volumeSlider"], False, padding = style.DEFAULT_PADDING )
self.GUI["volumeImage"] = gtk.Image()
self.GUI["volumeBox"].pack_start( self.GUI["volumeImage"], False, padding = style.DEFAULT_PADDING )
-
+
#-- Reverb --------------------------------------------
self.GUI["reverbBox"] = gtk.HBox()
self.GUI["mainBox"].pack_start( self.GUI["reverbBox"], padding = style.DEFAULT_PADDING )
@@ -249,7 +249,7 @@ class Drum( Popup ):
self.GUI["reverbBox"].pack_start( self.GUI["reverbSlider"], False, padding = style.DEFAULT_PADDING )
self.GUI["reverbImage"] = gtk.Image()
self.GUI["reverbBox"].pack_start( self.GUI["reverbImage"], False, padding = style.DEFAULT_PADDING )
-
+
self.GUI["generationSeparator"] = gtk.HSeparator()
self.GUI["mainBox"].pack_start( self.GUI["generationSeparator"], padding = style.DEFAULT_PADDING )
@@ -270,7 +270,7 @@ class Drum( Popup ):
self.GUI["beatsBox"].pack_start( self.GUI["beatsSlider"], False, padding = style.DEFAULT_PADDING )
self.GUI["beatsImage"] = gtk.Image()
self.GUI["beatsBox"].pack_start( self.GUI["beatsImage"], False, padding = style.DEFAULT_PADDING )
-
+
#-- Regularity ----------------------------------------
self.GUI["regularityBox"] = gtk.HBox()
self.GUI["mainBox"].pack_start( self.GUI["regularityBox"], padding = style.DEFAULT_PADDING )
@@ -297,7 +297,7 @@ class Drum( Popup ):
self.GUI["clearButton"] = gtk.Button( "Clear" )
self.GUI["clearButton"].connect( "clicked", self.handleClear )
self.GUI["generateBox"].pack_start( self.GUI["clearButton"], True, False, padding = style.DEFAULT_PADDING )
-
+
self.GUI["mainBox"].show_all()
def setBlock( self, block ):
@@ -342,7 +342,7 @@ class Drum( Popup ):
self.block.clear()
class Loop( Popup ):
-
+
def __init__( self, label, owner ):
Popup.__init__( self, label, owner )
@@ -377,7 +377,7 @@ class Loop( Popup ):
self.GUI["beatsBox"].pack_start( self.GUI["beatsSlider"], False, padding = style.DEFAULT_PADDING )
self.GUI["beatsImage"] = gtk.Image()
self.GUI["beatsBox"].pack_start( self.GUI["beatsImage"], False, padding = style.DEFAULT_PADDING )
-
+
#-- Regularity ----------------------------------------
self.GUI["regularityBox"] = gtk.HBox()
self.GUI["mainBox"].pack_start( self.GUI["regularityBox"], padding = style.DEFAULT_PADDING )
@@ -407,7 +407,7 @@ class Loop( Popup ):
self.GUI["recordButton"] = gtk.ToggleButton( "Record" )
self.GUI["recordButton"].connect( "toggled", self.handleRecord )
self.GUI["generateBox"].pack_start( self.GUI["recordButton"], True, False, padding = style.DEFAULT_PADDING )
-
+
#-- Preview -------------------------------------------
self.GUI["previewBox"] = gtk.HBox()
self.GUI["mainBox"].pack_start( self.GUI["previewBox"], padding = style.DEFAULT_PADDING )
@@ -471,7 +471,7 @@ class Loop( Popup ):
self.block = block
self.GUI["beatsAdjustment"].set_value( block.getData( "beats" ) )
self.GUI["regularityAdjustment"].set_value( block.getData( "regularity" ) )
-
+
root = block.getRoot()
if root.type == Block.Instrument:
self.instrument = { "id": root.getData( "id" ),
@@ -532,7 +532,7 @@ class Loop( Popup ):
return
if not self.settingBlock:
- self.curBeats = int(round( widget.get_value() ))
+ self.curBeats = int(round( widget.get_value() ))
self.block.setData( "beats", self.curBeats )
for n in self.owner.noteDB.getNotesByTrack( self.getPage(), 0, self ):
n.updateTransform( True )
@@ -546,14 +546,14 @@ class Loop( Popup ):
self.block.setData( "regularity", widget.get_value() )
def handleRegenerate( self, widget ):
- parameters = GenerationParameters(
- rythmRegularity = self.block.getData( "regularity" ),
- pitchRegularity = self.block.getData( "regularity" ) )
+ parameters = GenerationParameters(
+ rythmRegularity = [self.block.getData( "regularity" ) for x in range(4)],
+ pitchRegularity = [self.block.getData( "regularity" ) for x in range(4)])
self.owner._generateTrack( self.instrument["id"], self.curPage, 0, parameters, generator1 )
-
+
self.block.updateLoop()
-
+
if self.recordLoop:
self.recordLoop = self.owner._playLoop( self.instrument["id"], self.instrument["amplitude"], self.instrument["reverb"], [ self.curPage ], self.recordLoop, force = True )
@@ -707,8 +707,8 @@ class Loop( Popup ):
# backspace and del keys
if keyval == gtk.keysyms.Delete or keyval == gtk.keysyms.BackSpace:
if len( self.selectedNotes[0] ):
- self.owner.noteDB.deleteNotes(
- [ self.curPage, 0, len( self.selectedNotes[0] ) ]
+ self.owner.noteDB.deleteNotes(
+ [ self.curPage, 0, len( self.selectedNotes[0] ) ]
+ [ n.note.id for n in self.selectedNotes[0] ]
+ [ -1 ] )
self.block.updateLoop()
@@ -716,7 +716,7 @@ class Loop( Popup ):
self.owner.onKeyPress( widget, event )
#=======================================================
- # Drawing
+ # Drawing
def previewDraw( self ):
startX = self.previewDirtyRect.x
@@ -732,7 +732,7 @@ class Loop( Popup ):
# draw background
self.previewBuffer.draw_drawable( self.gc, self.sampleBg, 0, 0, 0, 0, self.previewDA.width-5, self.previewDA.height )
self.previewBuffer.draw_drawable( self.gc, self.sampleBg, self.sampleBg.endOffset, 0, self.previewDA.width-5, 0, 5, self.previewDA.height )
-
+
# draw beat lines
self.gc.set_line_attributes( Config.BEAT_LINE_SIZE, gtk.gdk.LINE_ON_OFF_DASH, gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER )
self.gc.foreground = self.colors["Beat_Line"]
@@ -799,7 +799,7 @@ class Loop( Popup ):
#self.owner.setPaused( True )
self.owner.pushInstrument( self.instrument )
self.owner.setKeyboardListener( self )
-
+
self.recordLoop = self.owner._playLoop( self.instrument["id"], self.instrument["amplitude"], self.instrument["reverb"], [ self.curPage ], force = True )
self.updatePlayhead()
self.recordTimeout = gobject.timeout_add( 20, self._record_timeout )
@@ -868,7 +868,7 @@ class Loop( Popup ):
tick = self.noteDB.getPage( self.curPage ).ticks
self.noteDB.updateNote( note.page, note.track, note.id, PARAMETER.DURATION, tick - note.cs.onset )
for n in self.noteDB.getNotesByTrack( self.curPage, 0 ):
- if n.cs.onset <= note.cs.onset:
+ if n.cs.onset <= note.cs.onset:
continue
if n.cs.onset > note.cs.onset and n.cs.onset < note.cs.onset + note.cs.duration:
self.noteDB.deleteNote( n.page, n.track, n.id )
@@ -878,13 +878,13 @@ class Loop( Popup ):
elif tick > note.cs.onset + note.cs.duration:
self.noteDB.updateNote( note.page, note.track, note.id, PARAMETER.DURATION, tick - note.cs.onset )
for n in self.noteDB.getNotesByTrack( self.curPage, 0 ):
- if n.cs.onset <= note.cs.onset:
+ if n.cs.onset <= note.cs.onset:
continue
if n.cs.onset > note.cs.onset and n.cs.onset < note.cs.onset + note.cs.duration:
self.noteDB.deleteNote( n.page, n.track, n.id )
else:
break
-
+
def _record_timeout( self ):
self.updatePlayhead()
if self.recordingNote:
@@ -1231,7 +1231,7 @@ class Loop( Popup ):
select = {}
intersectionY = [ self.marqueeRect[0][1], stop[1] ]
-
+
notes = []
track = self.noteDB.getNotesByTrack( self.getPage(), 0, self )
for n in range(len(track)):
@@ -1284,10 +1284,10 @@ class Loop( Popup ):
return int(( Config.MAXIMUM_PITCH - pitch ) * self.pixelsPerPitch )
def pixelsToPitchFloor( self, pixels ):
return int(-pixels*self.pitchPerPixel)
-
+
class Shortcut( Popup ):
-
+
def __init__( self, label, owner ):
Popup.__init__( self, label, owner )
@@ -1338,7 +1338,7 @@ class Shortcut( Popup ):
self.GUI["mainBox"].show_all()
self.key = None
-
+
def setBlock( self, block ):
self.ignoreToggle = True
@@ -1359,8 +1359,8 @@ class Shortcut( Popup ):
if self.key != None: # clear old key
self.ignoreToggle = True
self.GUI[self.key].set_active( False )
- self.key = None
- self.ignoreToggle = False
+ self.key = None
+ self.ignoreToggle = False
self.popdown( True )
else:
self.owner.onKeyPress( widget, event )
@@ -1377,7 +1377,7 @@ class Shortcut( Popup ):
if widget.get_active():
self.block.setData( "key", widget.key )
-
+
self.ignoreToggle = True
if self.key != None: # clear old key
@@ -1395,7 +1395,7 @@ class Shortcut( Popup ):
self.ignoreToggle = True
self.GUI[self.key].set_active( False )
self.key = None
- self.ignoreToggle = False
+ self.ignoreToggle = False
self.block.setData( "key", None )
diff --git a/common/Generation/GenerationConstants.py b/common/Generation/GenerationConstants.py
index 29dd28b..b961f4b 100755
--- a/common/Generation/GenerationConstants.py
+++ b/common/Generation/GenerationConstants.py
@@ -40,12 +40,12 @@ class GenerationConstants:
SCALE_BANK = [MAJOR, NATURAL_MINOR, LYDIEN, HARMONIC_MINOR, MYXOLYDIEN]
chooseDefault = random.randint(0,4)
- DEFAULT_DENSITY = RYTHM_DENSITY_BANK[chooseDefault]
- DEFAULT_RYTHM_REGULARITY = RYTHM_REGU_BANK[chooseDefault]
- DEFAULT_PITCH_REGULARITY = PITCH_REGU_BANK[chooseDefault]
- DEFAULT_STEP = PITCH_STEP_BANK[chooseDefault]
- DEFAULT_DURATION = DURATION_BANK[chooseDefault]
- DEFAULT_SILENCE = SILENCE_BANK[chooseDefault]
+ DEFAULT_DENSITY = [.25, .88, .72, .25] #RYTHM_DENSITY_BANK[chooseDefault]
+ DEFAULT_RYTHM_REGULARITY = [.75, .8, .85, .5] #RYTHM_REGU_BANK[chooseDefault]
+ DEFAULT_PITCH_REGULARITY = [.5, .8, 0, .9] #PITCH_REGU_BANK[chooseDefault]
+ DEFAULT_STEP = [.5, .3, 1, .85] #PITCH_STEP_BANK[chooseDefault]
+ DEFAULT_DURATION = [.8, 1, .8, 1] #DURATION_BANK[chooseDefault]
+ DEFAULT_SILENCE = [.2, .5, .25, .12] #SILENCE_BANK[chooseDefault]
DEFAULT_PATTERN = [random.randint(0,3) for x in range(4)]
DEFAULT_SCALE = SCALE_BANK[chooseDefault]
diff --git a/common/Generation/GenerationPitch.py b/common/Generation/GenerationPitch.py
index 4eaf8ae..4c34e8f 100644
--- a/common/Generation/GenerationPitch.py
+++ b/common/Generation/GenerationPitch.py
@@ -17,8 +17,8 @@ class GenerationPitch:
def drunkPitchSequence(self, length, parameters, table_pitch, trackId):
pitchSequence = []
append = pitchSequence.append
- numberOfPitch = int( ( 1 - (parameters.pitchRegularity*.8) ) * 10 + 1 )
- step = -(int(parameters.step * 10))
+ numberOfPitch = int( ( 1 - (parameters.pitchRegularity[trackId]*.8) ) * 10 + 1 )
+ step = -(int(parameters.step[trackId] * 10))
max = len(table_pitch)-1
nextValue = self.methodList[parameters.pattern[trackId]].getNextValue
tonique = GenerationConstants.DEFAULT_TONIQUE
diff --git a/common/Generation/GenerationRythm.py b/common/Generation/GenerationRythm.py
index a840804..5e1b31d 100644
--- a/common/Generation/GenerationRythm.py
+++ b/common/Generation/GenerationRythm.py
@@ -6,14 +6,14 @@ from common.Generation.GenerationConstants import GenerationConstants
class GenerationRythm:
- def celluleRythmSequence(self, parameters, barLength, trackInstrument=None ):
+ def celluleRythmSequence(self, parameters, barLength, trackId, trackInstrument=None ):
rythmSequence = [0, ]
self.count = 0
lastOnsetTime = 0
onsetLen = len(GenerationConstants.TABLE_ONSET_VALUES)
- onsetValue = int( ( 1 - (parameters.density*0.98+0.02) ) * onsetLen )
- onsetDeviation = int( ( 1 - parameters.rythmRegularity ) * 20 )
+ onsetValue = int( ( 1 - (parameters.density[trackId]*0.98+0.02) ) * onsetLen )
+ onsetDeviation = int( ( 1 - parameters.rythmRegularity[trackId] ) * 20 )
currentOnsetValue = onsetValue + ( random.randint( 0, onsetDeviation ) - ( onsetDeviation / 2 ) )
if currentOnsetValue < 0:
currentOnsetValue = 0
@@ -84,10 +84,10 @@ class GenerationRythm:
def xnoiseRythmSequence(self, parameters, barLength ):
rythmSequence = []
onsetTime = None
- randomParamScaler = parameters.rythmRegularity * 2 + 0.5
+ randomParamScaler = parameters.rythmRegularity[trackId] * 2 + 0.5
# need radioButton with 0 for random choose and each generator independant
whichRandomGenerator = random.randint(0, 4)
- maximumNumberOfNotes = int( (parameters.density) * GenerationConstants.MAX_NOTES_PER_BAR)
+ maximumNumberOfNotes = int( (parameters.density[trackId]) * GenerationConstants.MAX_NOTES_PER_BAR)
for i in range(maximumNumberOfNotes):
while onsetTime in rythmSequence:
@@ -120,7 +120,7 @@ class GenerationRythm:
return rythmSequence
def drumRythmSequence(self, parameters, trackInstrument, barLength ):
- density = sqrt(parameters.density)
+ density = sqrt(parameters.density[0])
rythmSequence = []
binSelection = []
downBeats = []
@@ -170,7 +170,7 @@ class GenerationRythm:
binCount = binSelection.count
binAppend = binSelection.append
for i in list:
- if rand() < ( parameters.rythmRegularity * downBeatRecurence ) and binCount( 1 ) < len( downBeats ):
+ if rand() < ( parameters.rythmRegularity[0] * downBeatRecurence ) and binCount( 1 ) < len( downBeats ):
binAppend( 1 )
else:
if binCount( 0 ) < len( downBeats ):
diff --git a/common/Generation/Generator.py b/common/Generation/Generator.py
index 4544d12..9bac77b 100755
--- a/common/Generation/Generator.py
+++ b/common/Generation/Generator.py
@@ -92,7 +92,7 @@ def generator1(
pitchSequence = makePitch.drumPitchSequence(len(rythmSequence), parameters, drumPitch, table_pitch )
else:
currentInstrument = instrument[pageId][trackId]
- rythmSequence = makeRythm.celluleRythmSequence(parameters, barLength, currentInstrument)
+ rythmSequence = makeRythm.celluleRythmSequence(parameters, barLength, trackId, currentInstrument)
pitchSequence = makePitch.drunkPitchSequence(len(rythmSequence),parameters, table_pitch, trackId)
gainSequence = makeGainSequence(rythmSequence)
@@ -105,14 +105,14 @@ def generator1(
instrument_id = Config.INSTRUMENTS[instrument[pageId][trackId]].instrumentId
for i in numOfNotes:
if drumPitch:
- if ( rand() * fillDrum ) > ( parameters.silence * .5 ):
+ if ( rand() * fillDrum ) > ( parameters.silence[0] * .5 ):
if fillDrum != 1:
if rythmSequence[i] not in trackOnsets or pitchSequence[i] not in trackPitchs:
append( CSoundNote( rythmSequence[i], pitchSequence[i], gainSequence[i], pan, durationSequence[i], trackId, instrument_id, 0.002, 0.098, 0.1, 0, 1000, False, 'edit' ) )
else:
append( CSoundNote( rythmSequence[i], pitchSequence[i], gainSequence[i], pan, durationSequence[i], trackId, instrument_id, 0.002, 0.098, 0.1, 0, 1000, False, 'edit' ) )
else:
- if rand() > parameters.silence:
+ if rand() > parameters.silence[trackId]:
append( CSoundNote( rythmSequence[i], pitchSequence[i], gainSequence[i], pan, durationSequence[i], trackId, instrument_id, 0.002, 0.1, 0.1, 0, 1000, False, 'edit' ) )
trackDictionary[ trackId ][ pageId ] = trackNotes
@@ -120,11 +120,11 @@ def generator1(
##################################################################################
# begin generate()
- table_duration = Utils.scale(parameters.articule, GenerationConstants.ARTICULATION_SCALE_MIN_MAPPING, GenerationConstants.ARTICULATION_SCALE_MAX_MAPPING, GenerationConstants.ARTICULATION_SCALE_STEPS)
table_pitch = GenerationConstants.SCALES[parameters.scale]
for trackId in trackIds:
if trackId == 4: # drum index
+ table_duration = Utils.scale(parameters.articule[0], GenerationConstants.ARTICULATION_SCALE_MIN_MAPPING, GenerationConstants.ARTICULATION_SCALE_MAX_MAPPING, GenerationConstants.ARTICULATION_SCALE_STEPS)
if parameters.rythmRegularity > 0.75:
streamOfPitch = GenerationConstants.DRUM_COMPLEXITY1
elif parameters.rythmRegularity > 0.5:
@@ -133,6 +133,9 @@ def generator1(
streamOfPitch = GenerationConstants.DRUM_COMPLEXITY3
else:
streamOfPitch = GenerationConstants.DRUM_COMPLEXITY4
+ else:
+ table_duration = Utils.scale(parameters.articule[trackId], GenerationConstants.ARTICULATION_SCALE_MIN_MAPPING, GenerationConstants.ARTICULATION_SCALE_MAX_MAPPING, GenerationConstants.ARTICULATION_SCALE_STEPS)
+
selectedPageCount = 0
lastPageId = 0
for pageId in pageIds:
@@ -151,11 +154,11 @@ def generator1(
trackOnsets = [n.onset for n in trackOfNotes]
trackPitchs = [n.pitch for n in trackOfNotes]
fillDrum = .5
- rythmRegTemp = parameters.rythmRegularity
- parameters.rythmRegularity = 0.5
+ rythmRegTemp = parameters.rythmRegularity[0]
+ parameters.rythmRegularity[0] = 0.5
for drumPitch in GenerationConstants.DRUM_COMPLEXITY4:
pageGenerate( parameters, trackId, pageId, trackOfNotes, drumPitch )
- parameters.rythmRegularity = rythmRegTemp
+ parameters.rythmRegularity[0] = rythmRegTemp
else:
fillDrum = 1
for drumPitch in streamOfPitch: