Conditional Modifiers

lastOf

Applies the given function every n cycles, starting from the last cycle.

  • n (number): how many cycles
  • func (function): function to apply
note("c3 d3 e3 g3").lastOf(4, x=>x.rev())

firstOf

Applies the given function every n cycles, starting from the first cycle.

  • n (number): how many cycles
  • func (function): function to apply
note("c3 d3 e3 g3").firstOf(4, x=>x.rev())

when

Applies the given function whenever the given pattern is in a true state.

  • binary_pat (Pattern):
  • func (function):
"c3 eb3 g3".when("<0 1>/2", x=>x.sub(5)).note()

chunk

Synonyms: slowChunk, slowchunk

Divides a pattern into a given number of parts, then cycles through those parts in turn, applying the given function to each part in turn (one part per cycle).

    "0 1 2 3".chunk(4, x=>x.add(7)).scale('A minor').note()

    chunkBack

    Synonyms: chunkback

    Like chunk, but cycles through the parts in reverse order. Known as chunk' in tidalcycles

      "0 1 2 3".chunkBack(4, x=>x.add(7)).scale('A minor').note()

      arp

      Selects indices in in stacked notes.

        note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
        .arp("0 [0,2] 1 [0,2]").slow(2)

        arpWith πŸ§ͺ

        Selects indices in in stacked notes.

          note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
          .arpWith(haps => haps[2])

          struct

          Applies the given structure to the pattern:

            note("c3,eb3,g3")
              .struct("x ~ x ~ ~ x ~ x ~ ~ ~ x ~ x ~ ~")
              .slow(4)

            mask

            Returns silence when mask is 0 or "~"

              note("c [eb,g] d [eb,g]").mask("<1 [0 1]>").slow(2)

              reset

              Resets the pattern to the start of the cycle for each onset of the reset pattern.

                s("<bd lt> sd, hh*4").reset("<x@3 x(3,8)>")

                restart

                Restarts the pattern for each onset of the restart pattern. While reset will only reset the current cycle, restart will start from cycle 0.

                  s("<bd lt> sd, hh*4").restart("<x@3 x(3,8)>")

                  hush

                  invert

                  Synonyms: inv

                  Swaps 1s and 0s in a binary pattern.

                    s("bd").struct("1 0 0 1 0 0 1 0".lastOf(4, invert))

                    pick

                    pick from the list of values (or patterns of values) via the index using the given pattern of integers

                    • pat (Pattern):
                    • xs (*):
                    note(pick("<0 1 [2!2] 3>", ["g a", "e f", "f g f g" , "g a c d"]))

                    squeeze

                    pick from the list of values (or patterns of values) via the index using the given pattern of integers. The selected pattern will be compressed to fit the duration of the selecting event

                    • pat (Pattern):
                    • xs (*):
                    note(squeeze("<0@2 [1!2] 2>", ["g a", "f g f g" , "g a c d"]))

                    After Conditional Modifiers, let’s see what Accumulation Modifiers have to offer.