Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TamTamMini.activity/Mini/RythmGenerator.py
diff options
context:
space:
mode:
Diffstat (limited to 'TamTamMini.activity/Mini/RythmGenerator.py')
-rw-r--r--TamTamMini.activity/Mini/RythmGenerator.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/TamTamMini.activity/Mini/RythmGenerator.py b/TamTamMini.activity/Mini/RythmGenerator.py
index 537f598..11df96e 100644
--- a/TamTamMini.activity/Mini/RythmGenerator.py
+++ b/TamTamMini.activity/Mini/RythmGenerator.py
@@ -4,9 +4,11 @@ import common.Config as Config
from common.Util.CSoundNote import CSoundNote
from common.Generation.GenerationConstants import GenerationConstants
from GenRythm import GenRythm
+from common.Util import InstrumentDB
def generator( instrument, nbeats, density, regularity, reverbSend ):
+ instrumentDB = InstrumentDB.getRef()
makeRythm = GenRythm()
noteDuration = GenerationConstants.DOUBLE_TICK_DUR / 2
@@ -18,15 +20,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 +38,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] ] #.name
rythmSequence = makeRythm.drumRythmSequence(currentInstrument, nbeats, density, regularity)
pitchSequence = makePitchSequence(len(rythmSequence), drumPitch )
@@ -54,16 +56,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: