PStep(n,value,default=0) >> Returns a pattern where every n-term is value, otherwise default.
PSum(n,total,**kwargs) >> Returns a pattern of length n, the sum of which is total. For example: PSum(3,8) -> P[3,3,2] PSum(5,4) -> P[1,0.75,0.75,0.75,0.75].
PRange(start,stop=None,step=None) >> Returns a pattern equivalent to Pattern(range(start,stop,step)).
PTri(start,stop=None,step=None) >> Returns a pattern equivalent to Pattern(range(start,stop,step)) with the inverted shape appended.
PEuclid(n,k) >> Returns the Euclidean rhythm that distributes n pulses as evenly as possible over k steps. e.g. PEuclid(3,8) returns P[1,0,0,1,0,0,1,0].
PSine(n=16) >> Returns values of one cycle of a sine wave divided into n parts.
PDur(n,k,dur=0.25) >> Returns the actual duration based on Euclidean rhythms (see PEuclid), where dur is the length of each step. e.g. PDur(3,8) returns P[0.75,0.75,0.5].
PBern(size=16,ratio=0.5) >> Returns a pattern of ones and zeros based on the ratio value (between 0 and 1). This is known as the Bernoulli sequence.
PBeat(string,start=0,dur=0.5) >> Returns a pattern of durations based on an input string, where non-spaces denote a pulse.
PSq(a=1,b=2,c=3)
Pattern generators
PRand(lo,hi,seed=None)/PRand([values]) >> Returns a series of random integers between lo and hi, inclusive. If hi is omitted, the range is 0 to lo. A list of values can be provided in place of the range and PRand returns a series of values chosen at random from the list.
PxRand(lo,hi)/PxRand([values]) >> Identical to PRand, but no elements are repeated.
PwRand([values], [weights]) >> Uses a list of weights to indicate how often items with the same index are selected from the list of values.
A weight of 2 means it is twice as likely to be picked as an item weighing 1.
P10(n)>> Returns a pattern of length n of a randomly generated series of ones and zeros.
*PAlt(pat1, pat2, patN) >> Returns a pattern generated by alternating the values in the specified sequences.
0, -2, 0, 8, 2, 1, 0, 9, 4, 3, 7, 0, -2, 0, 5 …
PJoin(patterns) >> Assembles a list of patterns.
PPairs(seq,func=) >> Links a sequence to a second sequence obtained by executing a function on the original. By default, this is lambda n: 8-n.
PQuicken(dur=0.5,stepsize=3,steps=6) >> Returns a group of delay amounts that gradually decrease.
PRhythm(durations) >> Converts all tuples / PGroups into delays, which are calculated with the PDur algorithm.
PShuf(seq) >> Returns a mixed version of seq. This example uses a function to automatically shuffle the list.
PStretch(seq,size) >> Returns seq as a pattern and is looped until its length is size, e.g. PStretch ([0,1,2], 5) returns P [0,1,2,0,1].
PStrum(n=4)
PStutter(seq,n=2) >> Creates a pattern so that each element in the array is repeated n times (n can be a pattern).
PZip(pat1, pat2, patN) >> Generates a pattern that ‘zips’ multiple patterns. PZip([0,1,2], [3,4]) creates the pattern P[(0,3),(1,4),(2,3),(0,4),(1,3),(2,4)].
PZip2(pat1,pat2,rule=) >> Like PZip, but only uses two patterns. Connects values if they meet the rule.
Pvar >> TimeVar, which saves lists instead of individual values (var,sinvar,linvar,expvar).
PWhite(lo,hi) >> Returns random floating point numbers between lo and hi.
PChain(mapping_dictionary) >> Based on a simple Markov chain with equal probabilities. Takes a dictionary of elements, states, and possible future states. Every future state has an equal chance of being selected. If a possible future state is not valid, a KeyError is raised.
PWalk(max=7,step=1,start=0) >> Returns a series of integers with each element an increment apart and with a value in the range of +/- the maximum. The first element can be selected with start.