Search code examples
supercollider

How do I add a random offset to values in a Pseq?


Given a Pseq similar to the following:

Pseq([1, 2, 3, 4, 5, 6, 7, 8], inf)

How would I randomise the values slightly each time? That is, not just randomly alter the 8 values once at initialisation time, but have a random offset added each time a value is sent to the stream?


Solution

  • Here's a neat way:

    (Pseq([1, 2, 3, 4, 5, 6, 7, 8], inf) + Pgauss(0, 0.1))
    

    First you need to know that Pgauss is just a pattern that generates gaussian random numbers. You can use any other kind of pattern such as Pwhite.

    Then you need to know the really pleasant bit: performing basic math operations on Patterns (as above) composes the patterns (by wrapping them in Pbinop).