I was wondering how I might implement brownian motion with Tidal. I was thinking you could use state to add a random value (with a specified range) to an existing variable. Unfortunately I don't know enough about haskell to go about implementing this
The use case is a control pattern like # pan "variable" where the variable is updating every cycle with a new number that's randomly incremented.
in the following code, the elements of the list are patterns, not plain numbers - I only use that to get some randomness. From that, scanl (+) 0 makes a randomly increasing sequence, and I play that, in parallel to its mirror image (decreasing). And I drown it in reverb. Have fun.
I don't know how this solution compares to other options, but there's already a sort of state implemented in Tidal: State Values | Tidal Cycles
Normally the way those states are updated is to always rise by 1 modulo some divisor. That has the strange effect that reversing the rising sequence results in another rising sequence, not a falling one. But anyway, if you hacked into that and replaced the function that increments things with a function that adds a random value, you'd have Brownian motion.
There's the nuance that random sequences in Tidal require IO. If you're a fan of purity -- which you should be -- you can restrict that IO to the top calling levels by writing deterministic functions that receive a random sequence from on high.