Ask Your Question
0

randomness

asked 2016-08-19 04:38:25 -0500

zzkt gravatar image

updated 2016-08-19 04:45:11 -0500

(further discussion of this thread https://github.com/tidalcycles/Tidal/...)

separate calls to rand (including irand, randcat, degrade, etc) during the same event(?) will produce the same results. this could be considered a bug or feature, however producing different random numbers for each call in the same event could be more interesting musically.

so consider this a request for an "impure RNG" and/or optional changes and/or discussions of the problems, merits or details of having "different" calls to a pRNG (during on event cycle) produce the same number from a random sequence or the next number from repeatable sequence of values from a given seed.

edit retag flag offensive close merge delete

Comments

I'll state the obvious and point out that pseudorandomness comes down to state, and 'proper' randomness comes down to I/O. Being all about constructing pure functions of time, Tidal can't really deal with either of these at the moment.. But it'd be interesting to look for good ways around both.

yaxu gravatar imageyaxu ( 2016-08-19 05:06:51 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2016-08-19 08:08:38 -0500

bgold gravatar image

As mentioned on Slack, here's one workaround:

let rand' x = Pattern $ \a -> [(a, a, timeToRand $ (+ x/100) $ midPoint a)]

which defines a new function where changing x will give you different random number streams.

edit flag offensive delete link more

Comments

sorry for asking this, but how can i do to, instead generating a "Pattern Double", generate "Pattern Int". This way would be possible to use in (not the best case) `midi5 $ n "0 0 ~ 0" # n (scale 48 72 $ rand' 100)`

lvm gravatar imagelvm ( 2016-08-19 10:03:13 -0500 )edit

A few ways, one is to put in a `liftA floor`. Like this: `midi5 $ n "0 0 ~ 0" # n (liftA floor $ scale 48 72 $ rand' 100)` In general, if you've got a function that works on Doubles, you can use it on Pattern Doubles using `liftA`

bgold gravatar imagebgold ( 2016-08-19 10:20:08 -0500 )edit

fantastic ! thanks :-)

lvm gravatar imagelvm ( 2016-08-19 10:21:03 -0500 )edit

Right! i forgot about floor (...), so another way would be `.... # n ((floor <$>) $ scale 48 72 $ rand' 100)` Either way, it doesn't produce what i expected haha

lvm gravatar imagelvm ( 2016-08-19 10:24:29 -0500 )edit

Yes, `<$>` is a synonym for `fmap`, and `liftA` is the Applicative Functor version of `fmap` (which is for regular Functors). How is it not what you expected? You should get a beat pattern of `0 0 ~ 0` with random notes between 48 and 72. The argument of `rand'` can be anything, 0.1, 1, pi...

bgold gravatar imagebgold ( 2016-08-19 11:12:14 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-08-19 04:38:25 -0500

Seen: 119 times

Last updated: Aug 19 '16