@ -35,10 +35,10 @@ percMidiChanStart = 0
@@ -35,10 +35,10 @@ percMidiChanStart = 0
# perc note
# set a static note for percussion tracks
percNote = 0
# set some notes for percussion tracks
percNotes = [ 0 , 1 , 2 , 3 ]
# perc track names
percNames = [ " kick " , " hh " , " sd " , " cp " , " ? " , " ? " , " bassline " , " ? " , " ? " ]
percNames = [ " kick " , " hh " , " sd " , " cp " , " five " ]
# for use generating sequences of 0's and 1's
#
#
@ -75,6 +75,7 @@ import sys
@@ -75,6 +75,7 @@ import sys
import random
import math
import re
import time
##################################################
@ -83,7 +84,11 @@ import re
@@ -83,7 +84,11 @@ import re
# seeds should be 6 digits or longer
input = sys . argv [ 1 ]
### FRONTMATTER ###
print ( " -- seed: " + str ( input ) )
print ( " -- generated at " + str ( time . time ( ) ) )
print ( " " )
########### THIS CHANGES EVERYTHING! #############
@ -91,11 +96,11 @@ print("-- seed: " + str(input))
@@ -91,11 +96,11 @@ print("-- seed: " + str(input))
random . seed ( input )
##################################################
indent = " "
indent = " "
# generate a bpm between lowest and highest
# looks like: cps = (BPM/60/4)
bpm = " cps = ( " + str ( random . randrange ( lowestBpm , highestBpm , 1 ) ) + " /60/4) "
print ( bpm + " \n " )
bpm = " set cps (" + str ( random . randrange ( lowestBpm , highestBpm , 1 ) ) + " /60/4) "
#print(bpm )
####################### FUNCTIONS ###################
@ -130,7 +135,7 @@ def generateBinary(busyness):
@@ -130,7 +135,7 @@ def generateBinary(busyness):
binary = [ 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ]
return binary
def genOnOff ( limit , busyness ) :
def genOnOff ( limit , busyness , struct ) :
" generate a series of 0 ' s and 1 ' s "
zeroesOnes = " "
@ -153,8 +158,14 @@ def genOnOff(limit,busyness):
@@ -153,8 +158,14 @@ def genOnOff(limit,busyness):
# >>> re.findall('.{1,2}', '123456789')
# ['12', '34', '56', '78', '9']
#zeroesOnes = re.findall('.{1,2}', zeroesOnes)
zeroesOnes = " struct \" { " + str ( zeroesOnes ) + " } % 16 \" "
return ( zeroesOnes )
if ( struct == 1 ) :
zeroesOnes = " struct \" { " + str ( zeroesOnes ) + " } % 16 \" "
return ( zeroesOnes )
else :
return ( zeroesOnes )
def euclid ( divider ) :
" generate a euclidean rhythm for tidalcycles "
@ -210,7 +221,7 @@ def offset():
@@ -210,7 +221,7 @@ def offset():
def every ( ) :
# TODO add a switch to choose divisible by 2/4/8 or not
bars = random . randint ( 2 , 16 )
return ( " $ every " + str ( bars ) + " " )
return ( indent + indent + " $ every " + str ( bars ) + " " )
def scramble ( ) :
divisions = [ 4 , 8 , 16 ]
@ -227,7 +238,7 @@ def stut():
@@ -227,7 +238,7 @@ def stut():
stut REPEATS VOLUME TIME
"""
# choose how many repeats
repeats = random . choice ( [ 1 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 4 , 4 , 4 , 4 , 4 , 4 5] )
repeats = random . choice ( [ 1 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 4 , 4 , 4 , 4 , 4 , 5 ] )
time = random . choice ( [ " 1/4 " , " 1/8 " , " 1/16 " , " 1/16 " , " 1/16 " ] )
return ( " stut " + str ( repeats ) + " 1 \" " + str ( time ) + " \" " )
@ -252,6 +263,26 @@ def bite():
@@ -252,6 +263,26 @@ def bite():
# we don't need to prepend with $ or ,
return ( " bite " + number + " \" { " + bit + " } % " + number + " \" " )
def offset ( ) :
offsetChoices = [ 0.125 , 0.125 , 0.125 , 0.125 , 0.1875 , 0.1875 , 0.1875 ]
return ( " ( " + str ( random . choice ( offsetChoices ) ) + " ~>) " )
def fills ( ) :
"""
Generate some things that would be cool at the end of phrases ,
eg whenmod 8 7 ( do something )
But nothing too intense
"""
# like whenmod 8 7
fillChoices = [ stut ( ) , " rev " , scramble ( ) ]
# how many filles do we want?
fills = " "
for i in range ( 1 , 10 ) :
# roll the dice
whenmods = [ " 8 7 " , " 4 3 " , " 16 15 " , " 16 14 " , " 32 31 " ]
fills = str ( random . choice ( fillChoices ) ) + " " + fills
return " whenmod " + str ( random . choice ( whenmods ) ) + " ( " + fills . rstrip ( ) + " ) "
########################### LISTS ##########################
@ -267,12 +298,27 @@ cyPats = ["[t*4]","[t*8]","[t~~~]","[t~~[~~~t]]","[<t~~~>~~~]"]
@@ -267,12 +298,27 @@ cyPats = ["[t*4]","[t*8]","[t~~~]","[t~~[~~~t]]","[<t~~~>~~~]"]
############### It's assemble time!! ###################
print ( " do " )
#print("")
# create "let" statements
for i in percNames :
#print("let "+i+"M = \"["+genOnOff(4,5,0)+"]\"")
print ( indent + " let " + i + " M = \" [1111] \" " )
#print("")
# actually assemble the stack!
print ( " p \" " + stackName + " \" " )
print ( indent + " p \" " + stackName + " \" " )
# stack stuff like bite, scramble, etc. will go here
print ( " $ whenmod 8 7 (scramble 4) " ) #
# roll the dice up to N times
for i in range ( 1 , 8 ) :
if ( random . randint ( 0 , 10 ) > 4 ) :
print ( indent + indent + " $ " + fills ( ) )
# how many "fun" things to add?
# a list of things to do to patterns to make them more interesting
@ -288,7 +334,7 @@ def funThings():
@@ -288,7 +334,7 @@ def funThings():
# for each iteration, choose an interestingThing
# indent + "every N" + ( rev )
wholeEnchilada = indent + str ( every ( ) + " ( " + str ( random . choice ( interestingThings ) ) + " ) \n " + wholeEnchilada ) . rstrip ( )
wholeEnchilada = str ( every ( ) + " ( " + str ( random . choice ( interestingThings ) ) + " ) \n " + wholeEnchilada ) . rstrip ( )
# using "every"
#return (every()+"("+bite()+")")
@ -298,12 +344,12 @@ def funThings():
@@ -298,12 +344,12 @@ def funThings():
#funThings()
# the top of the stack
print ( " $ stack [ " )
print ( indent + indent + " $ stack [ " )
# this is an empty track to make dealing with commas easier
# just 4 to the floor in case you want it
print ( indent + " -- four to the floor " )
print ( indent + " (#gain 0) $ struct \" [t*4] \" $ n \" 0 \" # midichan 0, " )
print ( indent + indent + " -- four to the floor " )
print ( indent + indent + " (#gain 0) $ struct \" [t*4] \" $ n \" 0 \" # midichan 0, " )
#print(",struct \"[t*4]\" $ n 0 # midichan 0")
@ -314,20 +360,28 @@ percMidiChan = 0
@@ -314,20 +360,28 @@ percMidiChan = 0
## this is where each "track" is generated
## percCount = how many rhythmic (non-melodic) tracks
## will be created
for i in range ( percCount ) :
for i in percNames :
print ( indent + " -- " + percNames [ percMidiChan ] + " ----------------- " )
print ( indent + indent + " -- " + percNames [ percMidiChan ] + " ----------------- " )
# this is here so there is the same thing at the start of
# each new track (so we know "whenmod" for instance always
# starts with $ and not ,)
print ( indent + " degradeBy 0 " )
#print(indent+indent+"degradeBy 0 ")
print ( indent + indent + " mask " + i + " M " )
#### FUN STUFF #####
# insert some funStuff, maybe
if ( random . randint ( 0 , 10 ) > 2 ) :
if ( random . randint ( 0 , 10 ) > 8 ) :
print ( funThings ( ) )
#### OFFSET ####
if ( random . randint ( 0 , 10 ) > 6 ) :
print ( indent + indent + " $ " + offset ( ) )
##### THE RHYTHMS #####
# choose between random, hardcoded, or euclidean rhythms
rChoice = random . choice ( [ 0 , 1 , 2 ] )
rhythm = " "
@ -348,7 +402,7 @@ for i in range(percCount):
@@ -348,7 +402,7 @@ for i in range(percCount):
elif ( i == 4 ) :
rhythm = str ( random . choice ( cyPats ) )
else :
rhythm = " t*16 "
rhythm = " t*4 "
rhythm = " struct \" " + rhythm + " \" "
elif ( rChoice == 1 ) :
@ -365,35 +419,35 @@ for i in range(percCount):
@@ -365,35 +419,35 @@ for i in range(percCount):
# choose a random value between 0 and 9
busyness = random . randrange ( 0 , 7 )
generateBinary ( busyness )
rhythm = str ( genOnOff ( percLength , busyness ) )
rhythm = str ( genOnOff ( percLength , busyness , 1 ) )
elif ( rChoice == 2 ) :
# GENERATE EUCLIDEAN RHYTHMS
rhythm = str ( euclid ( random . choice ( dividers ) ) )
#print(indent+euclid(random.choice(dividers)))
#print(indent+indent+ euclid(random.choice(dividers)))
#
else :
rhythm = " struct [t*4] "
print ( indent + " $ " + rhythm )
print ( indent + " $ n " + str ( percNote ) + " # midichan " + str ( percMidiChan ) + " , " )
print ( indent + indent + " $ " + rhythm )
print ( indent + indent + " $ n " + str ( random . choice ( percNotes ) ) + " # midichan " + str ( percMidiChan ) + " , " )
percMidiChan = percMidiChan + 1
# generate melodic tracks
melodicMidiChan = melodyMidiChanStart
#melodyMidiChanStart = 7
for i in range ( melodyCount ) :
print ( indent + " ----------------------- " )
print ( indent + " degradeBy 0 " )
print ( indent + indent + " ----------------------- " )
print ( indent + indent + " degradeBy 0 " )
#print(", ")
busyness = random . choice ( [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 6 , 6 , 6 , 7 , 7 , 7 , 7 , 8 , 8 , 8 , 9 , 9 ] )
if ( oneBar == 1 ) :
print ( indent + " $ " + genOnOff ( 16 , ( busyness ) ) )
print ( indent + " $ " + genNotes ( 1 ) )
print ( indent + indent + " $ " + genOnOff ( 16 , ( busyness ) , 1 ) )
print ( indent + indent + " $ " + genNotes ( 1 ) )
else :
genOnOff ( 32 , ( busyness ) )
print ( indent + " $ " + genNotes ( 1 ) )
print ( indent + " # midichan " + str ( melodicMidiChan ) + " + n (-36) " )
print ( indent + indent + " $ " + genNotes ( 1 ) )
print ( indent + indent + " # midichan " + str ( melodicMidiChan ) + " + n (-36) " )
melodicMidiChan = melodicMidiChan + 1
print ( " ] # sunvox " )
print ( indent + indent + " ] # sunvox " )