Imagine being able to conveniently import generators from a massive user library of modules. This will be a reality for Slipmat for two reasons:
- Users can easily write their own generators
- Users can easily share, import and remix generators
I built a list generator called range_plus(), which takes Python’s range() function a few steps farther. range() is limited to integers; range_plus() removes this restriction and allows for floats. range() supports a single increment step value; range_plus() additionally allows users to pass a list of increment step values that are chosen at random.
Here’s the working Python defintion for range_plus():
def range_plus(start, stop, random_steps=1): ''' Returns a list of successive incremented values chosen randomly from a list. Input: start -- Starting value stop -- End point random_steps -- A list of incremental values chosen at random or a single numeric value Output: return -- A numeric list ''' if stop < start: # Avoid infinite loop from bad input return  if not isinstance(random_steps, list): random_steps = [random_steps] L =  while start < stop: L.append(start) start = start + random.choice(random_steps) return L
I made sure to write the docstrings, to make life easier for anyone who may import my code later. Here's a Python interpreter session to test out some numbers:
>>> from MyListGenerators import range_plus >>> range_plus(0, 4, 0.5) [0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5] >>> range_plus(0, 4, [0.25, 0.25, 0.5, 0.75]) [0, 0.5, 1.0, 1.5, 1.75, 2.5, 3.0, 3.25, 3.75]
As applied to music, range_plus() would be a perfect fit for randomly generating rhythmic patterns, for things such as hi-hats.
@0 @range_plus(0, 4, [0.25, 0.25, 0.5, 0.75]) hat() @4 @range_plus(0, 4, [0.25, 0.25, 0.5, 0.75]) hat() @12 @range_plus(0, 4, [0.25, 0.25, 0.5, 0.75]) hat() @16 @range_plus(0, 4, [0.25, 0.25, 0.5, 0.75]) hat()
Here's is one scenario for what those patterns would look like in trigger notation:
Bar 1: x.x. x.xx ..x. xx.x Bar 2: xx.. x..x ..x. .xx. Bar 3: x..x ..x. xx.x .x.. Bar 4: x.x. .xxx .xxx x..x
The 'x' is a 16th note trigger, the '.' is a 16th note rest, and spaces are used to distinguish between each quarter note.