Random selection using end

I would like to take the following line:

d1 $sound "ho:5*8" # end "0.1"  How can I take the above line and change it so that it chooses different values of "end" randomly using an array? Such as: endval = [0.1, 0.25, 1]  Thanks. (update) I was able to get it working with: d1$ sound "ho:5*8" # end (choose [0.05,0.15,0.5])


However, when I add the "degradeBy" function, it doesn't choose the end values anymore:

d1 $degradeBy 0.9$ sound "ho:5*8" # end (choose [0.05,0.15,0.5])

edit retag close merge delete

Sort by » oldest newest most voted

This strange behaviour of degradeBy and choose is due to the way Tidal generates random numbers (i.e. as a function of time, rather than holding state). Basically degrade and choose are using the same stream of random numbers to decide whether to play, and which number to pick respectively..

Anyway, this is probably a bug to be fixed, but a workaround is to manipulate time slightly, so the random streams are out of alignment e.g.:

 d1 $degradeBy 0.9$ sound "ho:5*8" # end (density 1.01 $choose [0.05,0.15,0.5])  more Another workaround that @yaxu once suggested to me was to use the <~ or ~> functions to shift time before using degradeBy: d1$ degradeBy 0.9 $(8 <~)$ sound "ho:5*8" # end (choose [0.05, 0.125, 0.5])


I'm starting to get in the habit of doing this "shift" before almost all of my degrade functions because of the exact problem you're experiencing.

However, then your pattern will be "off" by 8 cycles, but maybe this is acceptable.

You can also then encapsulate the shift in a function that is (arguably) easier to remember and type:

let shift x p = (x <~) p

d1 $degradeBy 0.9$ shift 8 \$ sound "ho:5*8" # end (choose [0.05, 0.125, 0.5])

more