home/ atoms/ sonic-pi-knit-fn

knit creates a ring by repeating each value a specified number of times

knit :a, 2, :b, 3 returns a ring (:a, :a, :b, :b, :b). It alternates between values and their repetition counts, letting you express rhythmically weighted sequences concisely. Useful for basslines where some notes hold for multiple steps (knit :e1, 3, :c1, 1 = three beats on E1, one on C1). One of Sonic Pi’s ring constructors alongside ring, range, bools, and spread.

Examples

bass_line = (knit :e1, 3, :c1, 1) live_loop :bass do play bass_line.tick sleep 0.5 end

Assessment

Use knit to build a 4-beat pattern with two notes in an unequal rhythm. Explain how knit differs from simply repeating values in a ring literal.

“`knit` allows you to knit a sequence of repeated values”
corpus · sonic-pi-built-in-tutorial · chunk 17