Ask Your Question
2

Random selection using end

asked 2016-06-19 04:03:49 -0500

mitchk gravatar image

updated 2016-06-19 07:49:39 -0500

yaxu gravatar image

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 flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2016-06-19 07:49:15 -0500

yaxu gravatar image

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])

edit flag offensive delete link more
0

answered 2016-06-19 22:18:17 -0500

kindohm gravatar image

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])
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-19 04:03:49 -0500

Seen: 199 times

Last updated: Jun 19 '16