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

      fastChunk

      Synonyms: fastchunk

      Like chunk, but the cycles of the source pattern aren't repeated for each set of chunks.

        "<0 8> 1 2 3 4 5 6 7"
        .fastChunk(4, x => x.color('red')).slow(2)
        .scale("C2:major").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]")

          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("c,eb,g")
                .struct("x ~ x ~ ~ x ~ x ~ ~ ~ x ~ x ~ ~")
                .slow(2)

              mask

              Returns silence when mask is 0 or "~"

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

                reset

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

                  s("[<bd lt> sd]*2, hh*8").reset("<x@3 x(5,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]*2, hh*8").restart("<x@3 x(5,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

                      Picks patterns (or plain values) either from a list (by index) or a lookup table (by name). Similar to inhabit, but maintains the structure of the original patterns.

                      • pat (Pattern):
                      • xs (*):
                      note("<0 1 2!2 3>".pick(["g a", "e f", "f g f g" , "g c d"]))
                      sound("<0 1 [2,0]>".pick(["bd sd", "cp cp", "hh hh"]))
                      sound("<0!2 [0,1] 1>".pick(["bd(3,8)", "sd sd"]))
                      s("<a!2 [a,b] b>".pick({a: "bd(3,8)", b: "sd sd"}))

                      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.