Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Generation
diff options
context:
space:
mode:
authorOli <olivier.belanger@umontreal.ca>2007-08-24 09:01:41 (GMT)
committer Oli <olivier.belanger@umontreal.ca>2007-08-24 09:01:41 (GMT)
commit23166ec5ffeb26d0a4467e72a9f4dabea67b0133 (patch)
treec6e64209aa2816afb8a86c52ab1412dc5e451b98 /Generation
parente90310bd612fc920ffb2121b05b69342edc6e270 (diff)
META ALGO: tune form structure
Diffstat (limited to 'Generation')
-rwxr-xr-xGeneration/Generator.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/Generation/Generator.py b/Generation/Generator.py
index f12ef26..5fc2f71 100755
--- a/Generation/Generator.py
+++ b/Generation/Generator.py
@@ -41,7 +41,8 @@ def generator1(
nbeats, # map [ pageId : beats ]
trackIds, # list of trackIds to generate
pageIds, # list of pageIds to generate
- trackDictionary # map [ trackId : [ pageId : events ] ]
+ trackDictionary, # map [ trackId : [ pageId : events ] ]
+ nPagesCycle = 4 # META ALGO number of pages in a section
):
makeRythm = GenerationRythm()
@@ -81,7 +82,7 @@ def generator1(
append( ( barLength - onsetList[0] ) * proba( table_duration ))
return durationSequence
- def pageGenerate( parameters, trackId, pageId, trackOfNotes, drumPitch = None ):
+ def pageGenerate(parameters, trackId, pageId, trackOfNotes, drumPitch = None):
trackNotes = trackOfNotes
@@ -138,14 +139,14 @@ def generator1(
for pageId in pageIds:
barLength = Config.TICKS_PER_BEAT * nbeats[ pageId ]
trackOfNotes = []
- pageCycle = selectedPageCount % 4 # this should be fix in the meta algo
+ pageCycle = selectedPageCount % nPagesCycle
if instrument[pageId][trackId][0:4] == 'drum':
- if pageCycle in [1,2] and nbeats[pageId] == nbeats[lastPageId]:
+ if pageCycle not in [0,nPagesCycle-1] and nbeats[pageId] == nbeats[lastPageId]:
trackDictionary[trackId][pageId] = []
for n in trackDictionary[trackId][lastPageId]:
trackDictionary[trackId][pageId].append(n.clone())
- elif pageCycle == 3 and nbeats[pageId] == nbeats[lastPageId]:
+ elif pageCycle == (nPagesCycle-1) and nbeats[pageId] == nbeats[lastPageId]:
for n in trackDictionary[trackId][lastPageId]:
trackOfNotes.append(n.clone())
trackOnsets = [n.onset for n in trackOfNotes]
@@ -162,11 +163,6 @@ def generator1(
pageGenerate( parameters, trackId, pageId, trackOfNotes, drumPitch )
else:
- if (selectedPageCount % 2) == 0 or random.randint(0, 5) < 2 or selectedPageCount == 0 or nbeats[pageId] != nbeats[lastPageId]:
- pageGenerate( parameters, trackId, pageId, trackOfNotes, drumPitch = None )
- else:
- trackDictionary[trackId][pageId] = []
- for n in trackDictionary[trackId][lastPageId]:
- trackDictionary[trackId][pageId].append(n.clone())
+ pageGenerate( parameters, trackId, pageId, trackOfNotes, drumPitch = None )
selectedPageCount += 1
lastPageId = pageId