Continuous Signals

Signals are patterns with continuous values, meaning they have theoretically infinite steps. They can provide streams of numbers that can be sampled at discrete points in time.

saw

A sawtooth signal between 0 and 1.

    "c3 [eb3,g3] g2 [g3,bb3]".legato(saw.slow(4)).note()
    saw.range(0,8).segment(8).scale('C major').slow(4).note()

    sine

    A sine signal between 0 and 1.

      sine.segment(16).range(0,15).slow(2).scale('C minor').note()

      cosine

      A cosine signal between 0 and 1.

        stack(sine,cosine).segment(16).range(0,15).slow(2).scale('C minor').note()

        tri

        A triangle signal between 0 and 1.

          tri.segment(8).range(0,7).scale('C minor').note()

          square

          A square signal between 0 and 1.

            square.segment(2).range(0,7).scale('C minor').note()

            Ranges from -1 to 1

            There is also saw2, sine2, cosine2, tri2 and square2 which have a range from -1 to 1!

            rand

            A continuous pattern of random numbers, between 0 and 1.

              // randomly change the cutoff
              s("bd sd,hh*4").cutoff(rand.range(500,2000))

              perlin

              Generates a continuous pattern of perlin noise, in the range 0..1.

                // randomly change the cutoff
                s("bd sd,hh*4").cutoff(perlin.range(500,2000))

                irand

                A continuous pattern of random integers, between 0 and n-1.

                • n (number): max value (exclusive)
                // randomly select scale notes from 0 - 7 (= C to C)
                irand(8).struct("x(3,8)").scale('C minor').note()

                Random Modifiers

                These methods add random behavior to your Patterns.

                chooseCycles

                Picks one of the elements at random each cycle.

                  chooseCycles("bd", "hh", "sd").s().fast(4)
                  "bd | hh | sd".s().fast(4)

                  degradeBy

                  Randomly removes events from the pattern by a given amount. 0 = 0% chance of removal 1 = 100% chance of removal

                  • amount (number): a number between 0 and 1
                  s("hh*8").degradeBy(0.2)
                  s("[hh?0.2]*8")

                  degrade

                  Randomly removes 50% of events from the pattern. Shorthand for .degradeBy(0.5)

                    s("hh*8").degrade()
                    s("[hh?]*8")

                    undegradeBy

                    Inverse of Pattern#degradeBy: Randomly removes events from the pattern by a given amount. 0 = 100% chance of removal 1 = 0% chance of removal Events that would be removed by degradeBy are let through by undegradeBy and vice versa (see second example).

                    • amount (number): a number between 0 and 1
                    s("hh*8").undegradeBy(0.2)

                    sometimesBy

                    Randomly applies the given function by the given probability. Similar to Pattern#someCyclesBy

                    • probability (number|Pattern): a number between 0 and 1
                    • function (function): the transformation to apply
                    s("hh(3,8)").sometimesBy(.4, x=>x.speed("0.5"))

                    sometimes

                    Applies the given function with a 50% chance

                    • function (function): the transformation to apply
                    s("hh*4").sometimes(x=>x.speed("0.5"))

                    someCyclesBy

                    Randomly applies the given function by the given probability on a cycle by cycle basis. Similar to Pattern#sometimesBy

                    • probability (number|Pattern): a number between 0 and 1
                    • function (function): the transformation to apply
                    s("hh(3,8)").someCyclesBy(.3, x=>x.speed("0.5"))

                    someCycles

                    Shorthand for .someCyclesBy(0.5, fn)

                      s("hh(3,8)").someCycles(x=>x.speed("0.5"))

                      often

                      Shorthand for .sometimesBy(0.75, fn)

                        s("hh*8").often(x=>x.speed("0.5"))

                        rarely

                        Shorthand for .sometimesBy(0.25, fn)

                          s("hh*8").rarely(x=>x.speed("0.5"))

                          almostNever

                          Shorthand for .sometimesBy(0.1, fn)

                            s("hh*8").almostNever(x=>x.speed("0.5"))

                            almostAlways

                            Shorthand for .sometimesBy(0.9, fn)

                              s("hh*8").almostAlways(x=>x.speed("0.5"))

                              never

                              Shorthand for .sometimesBy(0, fn) (never calls fn)

                                s("hh*8").never(x=>x.speed("0.5"))

                                always

                                Shorthand for .sometimesBy(1, fn) (always calls fn)

                                  s("hh*8").always(x=>x.speed("0.5"))

                                  Next up: Conditional Modifiers