Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TamTamJam.activity/Jam/RythmGenerator.py
diff options
context:
space:
mode:
authorOli <olivier.belanger@umontreal.ca>2007-10-19 08:08:02 (GMT)
committer Oli <olivier.belanger@umontreal.ca>2007-10-19 08:08:02 (GMT)
commit3e9a586f404b70cda362cf888653de9c940fd849 (patch)
tree427a99619ebf947600a3cc2c0ef9437fb2953f09 /TamTamJam.activity/Jam/RythmGenerator.py
parent9307df223f0be4193a21fddd48e32ce15b9ed4ef (diff)
switch to instrumentDB
Diffstat (limited to 'TamTamJam.activity/Jam/RythmGenerator.py')
-rw-r--r--TamTamJam.activity/Jam/RythmGenerator.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/TamTamJam.activity/Jam/RythmGenerator.py b/TamTamJam.activity/Jam/RythmGenerator.py
index 537f598..d1ea46e 100644
--- a/TamTamJam.activity/Jam/RythmGenerator.py
+++ b/TamTamJam.activity/Jam/RythmGenerator.py
@@ -1,10 +1,13 @@
import random
+import common.Util.InstrumentDB as InstrumentDB
import common.Config as Config
from common.Util.CSoundNote import CSoundNote
from common.Generation.GenerationConstants import GenerationConstants
from GenRythm import GenRythm
+instrumentDB = InstrumentDB.getRef()
+
def generator( instrument, nbeats, density, regularity, reverbSend ):
makeRythm = GenRythm()
@@ -18,15 +21,15 @@ def generator( instrument, nbeats, density, regularity, reverbSend ):
filterCutoff = 1000
tied = False
mode = 'mini'
-
+
def makePitchSequence(length, drumPitch):
pitchSequence = []
append = pitchSequence.append
list = range(length)
max = len(drumPitch) - 1
for i in list:
- append(drumPitch[ random.randint( 0, max ) ] )
- return pitchSequence
+ append(drumPitch[ random.randint( 0, max ) ] )
+ return pitchSequence
def makeGainSequence( onsetList ):
gainSequence = []
@@ -36,16 +39,16 @@ def generator( instrument, nbeats, density, regularity, reverbSend ):
gain = random.uniform(GenerationConstants.GAIN_MID_MAX_BOUNDARY, GenerationConstants.GAIN_MAX_BOUNDARY)
elif ( onset % Config.TICKS_PER_BEAT) == 0:
gain = random.uniform(GenerationConstants.GAIN_MID_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MAX_BOUNDARY)
- else:
+ else:
gain = random.uniform(GenerationConstants.GAIN_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MIN_BOUNDARY)
append(gain)
- return gainSequence
-
+ return gainSequence
+
def pageGenerate( regularity, drumPitch ):
barLength = Config.TICKS_PER_BEAT * nbeats
#print 'pageGenerate drumPitch[0] ', drumPitch[0]
- currentInstrument = Config.INSTRUMENTS[ instrument ].kit[ drumPitch[0] ].name
+ currentInstrument = instrumentDB.instNamed[ instrument ].kit[ drumPitch[0] ]
rythmSequence = makeRythm.drumRythmSequence(currentInstrument, nbeats, density, regularity)
pitchSequence = makePitchSequence(len(rythmSequence), drumPitch )
@@ -54,16 +57,16 @@ def generator( instrument, nbeats, density, regularity, reverbSend ):
trackNotes = []
list = range(len(rythmSequence))
for i in list:
- trackNotes.append( CSoundNote( rythmSequence[i], pitchSequence[i], gainSequence[i],
- pan, noteDuration, trackId,
- Config.INSTRUMENTS[instrument].instrumentId, attack,
+ trackNotes.append( CSoundNote( rythmSequence[i], pitchSequence[i], gainSequence[i],
+ pan, noteDuration, trackId,
+ instrumentDB.instNamed[instrument].instrumentId, attack,
decay, reverbSend, filterType, filterCutoff, tied, mode))
return trackNotes
-##################################################################################
- # begin generate()
+##################################################################################
+ # begin generate()
if regularity > 0.75:
- streamOfPitch = GenerationConstants.DRUM_COMPLEXITY1
+ streamOfPitch = GenerationConstants.DRUM_COMPLEXITY1
elif regularity > 0.5:
streamOfPitch = GenerationConstants.DRUM_COMPLEXITY2
elif regularity > 0.25: