Tidal
Tidal copied to clipboard
manipulating time (or any float param) with euclidean patterns
In FoxDot there is a function called PDur that sequences note duration using euclidean patterns.
Here is how it's defined with some examples: PDur(n, k, start=0, dur=0.25) Returns the output of PEuclid as a series of durations where each element is a step of duration dur. The start keyword specifies the starting index of the Pattern. 1 >>> PDur(3, 8) 2 P[0.75, 0.75, 0.5] 3 >>> PDur(3, 8, 1) 4 P[0.75, 0.5, 0.75] 5 >>> PDur(3, 8, 1, 0.5) 6 P[1.5, 1.0, 1.5]
The function determines the relative duration between the 'true' boolean values and multiplies that with a user set value (0.25 by default), the pattern can also be rotated.
I put together a Haskell function to demonstrate this: import Data.List import Data.Maybe
rotate :: Int -> [a] -> [a] rotate _ [] = [] rotate n xs = zipWith const (drop n (cycle xs)) xs
pDur xs start dur = rotate (start + 1) . map ((*dur) . succ) . catMaybes . snd . mapAccumL (\a x -> if x /= 0 then (0, Just a) else (a+1, Nothing)) 0 $ xs
tidal> pDur [1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1] 0 0.25 [0.5,0.25,0.5,0.25,0.5,0.25,0.5,0.25,0.5,0.25,0.25]
The input of patternable euclids and the output into a workable time pattern type are still necessary to integrate into Tidal. The issue is more so with the former because as yaxu said, "patterns aren't a data structure, so you can't map over the elements inside them in this kind of stateful way."
Although my intention was to have this work similar to PDur in Foxdot, it would also be interesting/useful for using euclidean patterns with any function that accepts a floating point number pattern (slow, cps, legato, striate', speed, etc).