Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/common/Generation
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 /common/Generation
parent05958007515277d0adcd9ae161c12ddb0cfb6426 (diff)
meta algo
Diffstat (limited to 'common/Generation')
-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
4 files changed, 25 insertions, 22 deletions
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: