### Combined Euclidean Rhythm Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md An example combining Euclidean rhythm with basic sequencing. ```javascript s("bd?bjorklund(5,8) sd cp") // 5 bass drums distributed in 8 steps ``` -------------------------------- ### Node.js OSC Server Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md A basic Node.js example using the 'osc' library to create a server that listens for '/dirt/play' messages on port 9000. ```javascript // Node.js example const osc = require('osc'); const dgram = require('dgram'); const oscServer = new osc.Server(9000, '127.0.0.1'); oscServer.on('/dirt/play', (msg) => { console.log('Received:', msg.args); }); ``` -------------------------------- ### Set Sample Playback Start Offset Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Use the 'begin' pattern to specify the starting playback position of a sample, ranging from 0 to 1. ```javascript s("rave").begin("<0 0.25 0.5 0.75>") ``` -------------------------------- ### Combined Melodic Pattern Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md An example combining sequencing, parallel subdivision, and duration stretching for a melodic pattern. ```javascript note("[c d e f] [g a b c]/2") // first measure: c d e f // second measure: g a b c (stretched to 2 cycles) ``` -------------------------------- ### Web Audio Output Examples Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Demonstrates activating Web Audio output for drum patterns and melodic sequences. ```javascript s("bd sd hh cp").webaudio() note("c d e f g a b c").webaudio() ``` -------------------------------- ### Combined Drum Pattern Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md An example combining sequencing, parallel stacking, and repetition for a complex drum pattern. ```javascript s("[bd,cp] [sd hh*2] [bd,cp] [sd hh*2]") // (bd with cp) then (sd with 2 hhs) twice ``` -------------------------------- ### MIDI Hardware Synth Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Example of sending notes with varying gain and panning to a hardware synth via MIDI. The .pan() control maps to MIDI CC 10. ```javascript note("c c4 [g3,c4] f#4") .gain(0.8) .pan(sine) .midi() ``` -------------------------------- ### Synced External Sequencer Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Example showing how Strudel automatically handles incoming MIDI clock for timing synchronization when sending events via OSC and MIDI. ```javascript // Incoming MIDI clock adjusts timing note("c d e f") .osc() .midi() // Clock sync handled automatically ``` -------------------------------- ### Multi-Output Performance Setup Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Combine Web Audio, OSC, and MIDI outputs for a single pattern, allowing simultaneous playback through different systems. ```javascript const drums = s("[bd,cp] [sd hh]*2") drums .webaudio() // local synthesis .osc() // to SuperDirt .n(run(4)) .midi() // to hardware drum machine ``` -------------------------------- ### Mini Notation AST Example Source: https://github.com/tidalcycles/strudel/wiki/Technical-Manual An example Abstract Syntax Tree (AST) generated from mini notation. This structure represents patterns and elements, which is then used to construct Strudel patterns. ```json { "type_": "pattern", "arguments_": { "alignment": "h" }, "source_": [ { "type_": "element", "source_": "c3", "location_": { "start": { "offset": 1, "line": 1, "column": 2 }, "end": { "offset": 4, "line": 1, "column": 5 } } }, { "type_": "element", "location_": { "start": { "offset": 4, "line": 1, "column": 5 }, "end": { "offset": 11, "line": 1, "column": 12 } } "source_": { "type_": "pattern", "arguments_": { "alignment": "h" }, "source_": [ { "type_": "element", "source_": "e3", "location_": { "start": { "offset": 5, "line": 1, "column": 6 }, "end": { "offset": 8, "line": 1, "column": 9 } } }, { "type_": "element", "source_": "g3", "location_": { "start": { "offset": 8, "line": 1, "column": 9 }, "end": { "offset": 10, "line": 1, "column": 11 } } } ] }, } ] } ``` -------------------------------- ### Combined Polymetric Pattern Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md An example demonstrating a polymetric pattern using angle brackets to layer sequences with different lengths. ```javascript note("") // 3 notes against 4 notes (polymetric) ``` -------------------------------- ### Web Audio Helper Function Import Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md Import the function to get the Web Audio context, necessary for audio output. ```javascript import { getAudioContext } from '@strudel/webaudio' ``` -------------------------------- ### Pattern for Sound Output Source: https://github.com/tidalcycles/strudel/wiki/Technical-Manual This example shows how to define a musical pattern with various properties like note, sound source, gain, and cutoff modulation using the Web Audio API. ```javascript note("[c2(3,8) [ bb1]]") // sets frequency .s("") // sound source .gain(.5) // turn down volume .cutoff(sine.range(200,1000).slow(4)) // modulated cutoff .slow(2) .out().logValues() ``` -------------------------------- ### Hip-Hop Drum Pattern Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md An example of a hip-hop drum pattern using mini notation, demonstrating combinations of repeated elements and panning/gain controls. ```javascript s("bd*2 [sd cp]*2") .pan("<0 1 0.5>") .gain("<1 0.8 0.9>") ``` -------------------------------- ### Arpeggiated Melody Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md An example of an arpeggiated melody using mini notation for notes and applying varying gain over time. The `!` operator is used for repeated gain values. ```javascript note("[c e g b]*2").gain(".8!4 1!4") ``` -------------------------------- ### render(start, end) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Returns a string representation of a pattern within a specified time range. ```APIDOC ## render(start, end) ### Description Get string representation of pattern. ### Parameters #### Path Parameters - **start** (number) - Required - The starting time or index. - **end** (number) - Required - The ending time or index. ### Request Example ```javascript s("bd sd").render(0, 2) ``` ``` -------------------------------- ### Polyrhythmic Groove Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md Creates a polyrhythmic groove by stacking multiple patterns with different rhythms and panning. The `stack()` function is used to combine them. ```javascript stack( s("bd*3").pan(0), s("sd*2").pan(1), s("cp*5") ) ``` -------------------------------- ### Basic Atom Examples Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md Represent single events or sequences of events using basic atom syntax. ```javascript s("bd") // single event: bass drum s("bd sd") // sequence: bass drum, snare note("c") // single note: C note("c d e") // sequence: C, D, E ``` -------------------------------- ### Configure Default Outputs and OSC/MIDI Settings Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Defines the default audio output methods and configuration for OSC and MIDI communication. Ensure the OSC host and port match your server setup. ```javascript // Configure default outputs export const defaultOutputs = ['webaudio', 'osc'] export const osc = { host: 'localhost', port: 9000 } export const midi = { out: 1 // default MIDI output } ``` -------------------------------- ### Modal Interchange Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/5-tonal-music-theory.md Demonstrates modal interchange by switching between major and minor modes of the same key. This technique adds color and variation to progressions. ```javascript note("0 2 4 6") .scale("") // switches between major and minor modes ``` -------------------------------- ### getAudioContext() Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Get the current Web Audio API AudioContext. ```APIDOC ## getAudioContext() ### Description Get the current Web Audio API AudioContext. ### Method `getAudioContext()` - Function ### Returns Web Audio API AudioContext instance ### Properties - `currentTime` - Current playback time in seconds - `sampleRate` - Sample rate (typically 44100 or 48000) - `destination` - Master audio output node ### Example ```javascript const ctx = getAudioContext() console.log(ctx.currentTime) console.log(ctx.sampleRate) ``` ``` -------------------------------- ### Common Mini Notation Patterns Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md Examples of common patterns using mini notation for drum beats, melodic sequences, and polymetric arrangements. ```javascript // Drum patterns "[bd cp] [sd hh]*2" "bd ~ sd ~" "[bd,cp] [sd hh] [bd,cp] [sd hh]" // Melodic patterns "c d e f g a b c" "[c e g] [d f a]" "c d e f / 2" // Polymetric "" "" ``` -------------------------------- ### MIDI Drum Machine Example Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Send drum patterns to MIDI channel 10, specifying MIDI drum note numbers and varying gain. The .n() control maps to MIDI note numbers. ```javascript // MIDI channel 10 (drums) s("bd sd hh cp") .n("0 1 36 38") // MIDI drum notes .gain("<1 0.8 0.9>") .midi() ``` -------------------------------- ### Pure Data OSC Receiver Setup Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Configure a Pure Data patch to receive OSC messages on port 9000 by using the 'udpreceive' object. ```pd [udpreceive 9000] ``` -------------------------------- ### render(start, end, includeContext = false) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/1-pattern-class.md Renders the pattern as a human-readable string representation of its Haps within a specified time range. Optionally includes context in the output. ```APIDOC ## render(start, end, includeContext = false) → string ### Description Renders pattern as human-readable string. ### Parameters #### Path Parameters - **start** (number) - Required - Start time - **end** (number) - Required - End time - **includeContext** (boolean) - Optional - Include context in output ### Returns String representation of haps ### Example ```javascript pattern.render(0, 2) ``` ``` -------------------------------- ### Send Pattern Events to SuperDirt via OSC Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Example of sending drum and note patterns to SuperCollider/SuperDirt using the .osc() method. ```javascript // Send to SuperCollider/SuperDirt s("bd*2 [sd cp]").osc() note("c d e f").gain(0.8).osc() ``` -------------------------------- ### Example Hap Value Source: https://github.com/tidalcycles/strudel/wiki/Technical-Manual A sample JSON object representing a 'Hap' value with properties for note, sound source, gain, and cutoff. ```json { "note": "a4", "s": "sawtooth", "gain": 0.5, "cutoff": 267 } ``` -------------------------------- ### run(length) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Generates a sequence of numbers starting from 0 up to (but not including) the specified length. ```APIDOC ## run(length) → Pattern Generate sequence 0, 1, 2, ... length-1. ```javascript run(8) // 0 1 2 3 4 5 6 7 run(5).fast(2) // repeated 4 times per cycle ``` ``` -------------------------------- ### timeCat(...entries) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Concatenates patterns with explicit timing specifications using `Fraction` objects to define start times. ```APIDOC ## timeCat(...entries) → Pattern Concatenate with explicit timing. ```javascript timeCat([Fraction(1), note("c")], [Fraction(2), note("d")]) ``` ``` -------------------------------- ### graph(start, end, height = 8) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/1-pattern-class.md Creates an ASCII graph representation of the pattern's values over a specified time range and height. ```APIDOC ## graph(start, end, height = 8) → string ### Description Creates ASCII graph of pattern values. ### Parameters #### Path Parameters - **start** (number) - Required - Start time - **end** (number) - Required - End time - **height** (number) - Optional - Height of the graph ### Example ```javascript pattern.graph(0, 2, 8) ``` ``` -------------------------------- ### Get String Representation of Pattern Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Returns a string representation of a pattern within a specified start and end range. Useful for inspecting pattern content. ```javascript s("bd sd").render(0, 2) ``` -------------------------------- ### graph(start, end, height) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Generates an ASCII graph representation of a pattern's values within a specified range and height. ```APIDOC ## graph(start, end, height) ### Description Get ASCII graph of pattern values. ### Parameters #### Path Parameters - **start** (number) - Required - The starting time or index. - **end** (number) - Required - The ending time or index. - **height** (number) - Required - The height of the ASCII graph. ### Request Example ```javascript n(run(4)).graph(0, 1, 8) ``` ``` -------------------------------- ### Import Strudel Utilities Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/0-strudel-technical-reference.md Import utility modules for mini notation, music theory, Web Audio, and OSC. ```javascript import { m, mini, miniAllStrings } from '@strudel/mini' import { scale, transpose, chord } from '@strudel/tonal' import { webaudio } from '@strudel/webaudio' import { osc } from '@strudel/osc' ``` -------------------------------- ### Start SuperDirt Listener Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md This SuperCollider code starts the SuperDirt listener, which is required for receiving OSC messages from Strudel. ```supercollider ( SuperDirt.start; ) ``` -------------------------------- ### Function Arguments with Patterns Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md Demonstrates how to use static values, mini notation, patterns, and continuous signals as arguments for functions like 'gain'. ```javascript // All can be patterns or static values p.gain(0.8) // Static p.gain("0.5 0.8 1") // Mini notation p.gain(pure(0.8)) // Pattern p.gain(sine) // Continuous signal p.gain(sine.range(0.5, 1)) // Mapped signal p.gain("<0.5 0.8 1>") // Angle bracket pattern ``` -------------------------------- ### range(start, end) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Generates a sequence of numbers from a specified start value to an end value, inclusive. The sequence can be ascending or descending. ```APIDOC ## range(start, end) → Pattern Generate numbers from start to end (inclusive). ```javascript range(0, 7) // 0 1 2 3 4 5 6 7 range(5, 1) // 5 4 3 2 1 range(-3, 3) // -3 -2 -1 0 1 2 3 ``` ``` -------------------------------- ### Generate a Numeric Sequence (run) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md The `run(length)` function generates a pattern that outputs integers starting from 0 up to `length - 1`. Useful for indexing or creating simple progressions. ```javascript run(8) // 0 1 2 3 4 5 6 7 run(5).fast(2) // repeated 4 times per cycle ``` -------------------------------- ### Load and Play Custom Samples Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Load custom audio samples from local paths using the 'samples' function and then play them with the 's' function. ```javascript import { samples } from '@strudel/webaudio' samples({ kick: 'path/to/kick.wav', snare: 'path/to/snare.wav' }) s("kick snare kick snare").webaudio() ``` -------------------------------- ### Import Tonal Utilities Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/5-tonal-music-theory.md Import necessary functions from the @strudel/tonal package for music theory operations. ```javascript import { scale, transpose, chord, anchor, offset } from '@strudel/tonal' ``` -------------------------------- ### Mini Notation with Pattern Controls Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md Demonstrates using mini notation strings with pattern controls like `.gain()`, `.pan()`, and `.attack()`. ```javascript s("bd sd hh cp").gain("1 0.8 0.6 0.4") ``` ```javascript note("c d e f").attack("0 .1 .2 .3") ``` ```javascript s("bd*4").pan("<0 0.25 0.5 0.75>") ``` -------------------------------- ### Generate a Numeric Range (range) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md The `range(start, end)` function creates a pattern that generates numbers sequentially from `start` to `end`, inclusive. It handles both ascending and descending ranges. ```javascript range(0, 7) // 0 1 2 3 4 5 6 7 range(5, 1) // 5 4 3 2 1 range(-3, 3) // -3 -2 -1 0 1 2 3 ``` -------------------------------- ### range(min, max) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Generates an array of numbers starting from 'min' up to and including 'max'. ```APIDOC ## range(min, max) ### Description Generate number array from min to max. ### Parameters #### Path Parameters - **min** (number) - Required - The starting number of the range. - **max** (number) - Required - The ending number of the range. ### Request Example ```javascript range(0, 5) // [0, 1, 2, 3, 4, 5] range(-2, 2) // [-2, -1, 0, 1, 2] ``` ``` -------------------------------- ### Play GitHub Dirt-samples Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Access Freesound-based drum samples from GitHub using the 's' function and '.webaudio()' method. ```javascript s("bd sd hh cp").webaudio() ``` -------------------------------- ### Import Web Audio Modules Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Import the necessary functions for Web Audio integration from the @strudel/webaudio package. ```javascript import { webaudioRepl, getAudioContext } from '@strudel/webaudio' ``` -------------------------------- ### Import Core Utilities Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Import essential utility functions from the @strudel/core package. These functions are fundamental for creating and manipulating musical patterns. ```javascript import { pure, silence, nothing, sequence, stack, fastcat, slowcat, run, range, degrees, chooseIn, shuffle, pickWeighted, euclid, euclidRot, rand, sometimes, lfn } from '@strudel/core' ``` -------------------------------- ### Hap endClipped Property Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/2-types-and-datastructures.md Gets the end time of the Hap, considering any clipping applied. Returns a Fraction object. ```javascript const end = hap.endClipped ``` -------------------------------- ### Hap duration Property Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/2-types-and-datastructures.md Gets the duration of the Hap, accounting for its whole timespan and any clipping. Returns a Fraction object. ```javascript const dur = hap.duration ``` -------------------------------- ### Combine Web Audio and OSC Outputs Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Send a pattern's output to both the local Web Audio synthesis and an OSC server simultaneously. ```javascript pattern.webaudio().osc() ``` -------------------------------- ### webaudio() Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Activates Web Audio output for a pattern. All events will be sent to the audio synthesis engine. ```APIDOC ## webaudio() ### Description Activates Web Audio output for a pattern. All events will be sent to the audio synthesis engine. ### Method `webaudio()` - Pattern method ### Example ```javascript note("c d e f").webaudio() s("bd sd hh cp").webaudio() note("c d e f g a b c").webaudio() ``` ``` -------------------------------- ### Select Sound by Name Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/3-controls-and-parameters.md Use the `s` function to select a sound or sample to play. Supports static names, patterns, and indexing with gain. ```javascript s("bd sd [~ bd] sd") ``` ```javascript s("bd:0 bd:1 sd:0") // with index ``` ```javascript s("bd:0:0.8") // with index and gain ``` -------------------------------- ### Output Methods Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md Direct Strudel patterns to various output destinations. Choose between Web Audio, OSC, MIDI, serial data, or console logging. ```javascript p.webaudio() // Output to Web Audio p.dough() // Alias for webaudio p.osc() // Send OSC messages p.midi() // Send MIDI p.serial() // Send serial data p.log() // Log to console p._scope() // Show waveform p._spectrum() // Show spectrum ``` -------------------------------- ### Compressor Settings Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/3-controls-and-parameters.md Applies a dynamics compressor with specified parameters: threshold, ratio, knee, attack, and release. ```javascript s("bd sd").compressor("-20:20:10:0.002:0.02") ``` -------------------------------- ### TimeSpan Constructor Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/2-types-and-datastructures.md Instantiates a new TimeSpan object representing a time interval. Use this to define specific start and end points. ```javascript new TimeSpan(Fraction(0), Fraction(1)) ``` -------------------------------- ### Hap isInFuture Method Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/2-types-and-datastructures.md Checks if a Hap object starts after the specified current time. Useful for scheduling or predicting future events. ```javascript if (hap.isInFuture(now)) { // coming up } ``` -------------------------------- ### Import Strudel Networking Modules Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Import necessary modules for OSC, MIDI, and serial communication from the Strudel library. ```javascript import { } from '@strudel/osc' import { midi } from '@strudel/midi' import { serial } from '@strudel/serial' ``` -------------------------------- ### Get Web Audio Context Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Retrieve the current Web Audio API AudioContext to access its properties like currentTime and sampleRate. ```javascript const ctx = getAudioContext() console.log(ctx.currentTime) console.log(ctx.sampleRate) ``` -------------------------------- ### Creating Fractions Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/2-types-and-datastructures.md Instantiate Fraction objects from numbers or strings for precise rational number representation. ```javascript import Fraction from '@strudel/core' const f1 = Fraction(1, 2) // 1/2 const f2 = Fraction(0.5) // converts to 1/2 const f3 = Fraction('1/3') // parses string ``` -------------------------------- ### Apply Dynamics Processing Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Use the 'compressor' method with specific parameters for dynamics processing and adjust the overall gain. ```javascript s("bd*8") .compressor("-20:20:10:0.002:0.02") .gain(1.5) ``` -------------------------------- ### Basic Scheduling Loop Source: https://github.com/tidalcycles/strudel/wiki/Technical-Manual This snippet demonstrates a simplified scheduling loop that queries events at a set interval and processes them using Web Audio API. ```javascript let step = 0.5; // query interval in seconds let tick = 0; // how many intervals have passed let pattern = seq('c3', ['e3', 'g3']); // pattern from user setInterval(() => { const events = pattern.queryArc(tick * step, ++tick * step); events.forEach((event) => { console.log(event.showWhole()); const o = getAudioContext().createOscillator(); o.frequency.value = getFreq(event.value); o.start(event.whole.begin); o.stop(event.whole.begin + event.duration); o.connect(getAudioContext().destination); }); }, step * 1000); // query each "step" seconds ``` -------------------------------- ### Range Operator for Generating Ranges Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md The `?range(start, stop, step)` operator generates a sequence of numbers within a specified range and step. ```javascript n("0?range(7)") // range from 0 to 7: 0 1 2 3 4 5 6 7 n("0?range(0,8,2)") // range 0-8 step 2: 0 2 4 6 8 ``` -------------------------------- ### Mini Notation Syntax Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md A concise syntax for defining musical patterns, including single values, sequences, groups, stacks, repetitions, and operators. ```javascript "bd" // Single value "bd sd" // Sequence (2 items) "bd sd hh cp" // Sequence (4 items) "~" // Silence "[bd sd]" // Group (sequence) "{bd hh, sd}" // Stack (parallel) "bd*4" // Repeat 4x "bd/2" // Stretch over 2 cycles "/2" // Pattern selector / polyrhythm "bd?fast(2)" // Operator: fast "bd?slow(0.5)" // Operator: slow "bd?euclid(5,8)" // Operator: euclidean "bd?degrade(0.5)" // Operator: random remove "0..7" // Range 0-7 ``` -------------------------------- ### Use Nothing Pattern Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/1-pattern-class.md Represents a pattern that returns no events and has a duration of 0. Useful for combining with other patterns without adding events, for example, using 'stack'. ```javascript nothing.stack(note("c")) ``` -------------------------------- ### Concatenate Patterns with Explicit Timing Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Use `timeCat` to create a sequence of patterns where each pattern is associated with a specific `Fraction` representing its start time within the cycle. ```javascript timeCat([Fraction(1), note("c")], [Fraction(2), note("d")]) ``` -------------------------------- ### Sound Selection and Synthesis Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md Choose specific samples, synths, or define notes and frequencies for sound generation. ```javascript s("bd sd hh") // Sample/synth n("0 1 2") // Sample index note("c d e f") // MIDI note note("c4 d4 e4") // Note with octave freq(440) // Frequency in Hz source(oscNode) // Custom Web Audio node bank("roland") // Sample bank prefix ``` -------------------------------- ### Get ASCII Graph of Pattern Values Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Generates an ASCII graph representing the values of a pattern over a specified range and height. Useful for visualizing pattern data. ```javascript n(run(4)).graph(0, 1, 8) ``` -------------------------------- ### Import Mini Notation Functions Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md Import the necessary functions for using mini notation from the '@strudel/mini' package. ```javascript import { m, mini, h, minify } from '@strudel/mini' ``` -------------------------------- ### Activate Web Audio Output Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Use the .webaudio() method to send pattern events to the Web Audio synthesis engine for playback. ```javascript note("c d e f").webaudio() ``` -------------------------------- ### Activate Dough Synthesis Engine Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Use the .dough() method as an alias for .webaudio() to specifically target the superdough synthesis engine. ```javascript note("c d e f").dough() ``` -------------------------------- ### Hap hasOnset Method Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/2-types-and-datastructures.md Checks if a Hap object's onset (start of the whole timespan) matches its part's onset. Useful for detecting events that begin precisely at their scheduled time. ```javascript if (hap.hasOnset()) { console.log("Event starts here") } ``` -------------------------------- ### List Available MIDI Ports Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Retrieve a list of available MIDI output ports. Requires importing the getMidiPorts function. ```javascript import { getMidiPorts } from '@strudel/midi' getMidiPorts() // [{name: "Port 1"}, {name: "Port 2"}, ...] ``` -------------------------------- ### _spectrum() Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Adds FFT spectrum analysis and visualization to the output. ```APIDOC ## _spectrum() ### Description Adds FFT spectrum analysis and visualization to the output. ### Method `_spectrum()` - Pattern method ### Example ```javascript note("c d e f")._spectrum() ``` ``` -------------------------------- ### Combining Multiple Output Methods Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md Chain multiple output methods together to send Strudel patterns to several destinations simultaneously, such as Web Audio, OSC, and MIDI. ```javascript p.webaudio().osc() // Web Audio + OSC p.webaudio().midi() // Web Audio + MIDI p.osc().midi() // OSC + MIDI p.webaudio().osc().midi() // All three ``` -------------------------------- ### Enable Automatic Mini Notation Parsing Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md Enables automatic mini notation parsing for all strings within patterns. Import `miniAllStrings` and call it once. ```javascript import { miniAllStrings } from '@strudel/mini' miniAllStrings() ``` -------------------------------- ### Random.early Method Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/2-types-and-datastructures.md Creates deterministic random sequences based on an offset amount. Allows for repeatable random patterns when seeded. ```javascript // seed creates repeatable random const seeded = rand.early(0.001) ``` -------------------------------- ### s(sound) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/3-controls-and-parameters.md Selects a sound or sample to play. It can take a sound name or a pattern of sound names. Aliases include `sound()`. ```APIDOC ## s(sound) → Pattern ### Description Select a sound or sample to play. ### Parameters #### Path Parameters - **sound** (string | Pattern) - Required - Sound name from loaded samples ### Request Example ```javascript s("bd sd [~ bd] sd") s("bd:0 bd:1 sd:0") // with index s("bd:0:0.8") // with index and gain ``` ``` -------------------------------- ### euclidRot(pulses, steps, rotation) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Generates a Euclidean rhythm pattern with rotation. It takes the number of hits (pulses), the total number of steps available, and the rotation amount in steps as input. ```APIDOC ## euclidRot(pulses, steps, rotation) ### Description Euclidean rhythm with rotation. ### Parameters #### Path Parameters - **pulses** (number) - Required - Number of hits - **steps** (number) - Required - Total steps available - **rotation** (number) - Required - Rotation amount in steps ### Request Example ```javascript s("bd").euclidRot(3, 8, 1) // rotate pattern by 1 step ``` ``` -------------------------------- ### Basic Pattern Creation Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/0-strudel-technical-reference.md Create single values, silence, or zero-duration patterns. ```javascript pure(value) ``` ```javascript silence ``` ```javascript nothing ``` -------------------------------- ### Control LED Brightness via Serial Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Map a musical pattern to a 0-127 range and send it over the serial port to control hardware like an LED's brightness. ```javascript n(run(8)) .scale("C:major") .add(60) // map to 0-127 range .serial() ``` -------------------------------- ### Import Strudel Core Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/0-strudel-technical-reference.md Import essential components from the Strudel core library for pattern generation and manipulation. ```javascript import { Pattern, Hap, TimeSpan, Fraction, pure, silence, sequence, stack, fastcat, note, s, gain, run, range, rand, euclid, euclidRot } from '@strudel/core' ``` -------------------------------- ### Send Pattern Events via OSC Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Use the .osc() method to send pattern events to an OSC server. Requires an OSC server running on localhost:9000 and the Web Audio API. ```javascript s("bd sd hh cp").osc() note("c d e f").osc() ``` -------------------------------- ### Send Pattern Events via MIDI Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Use the .midi() method to send pattern events as MIDI messages. This is useful for controlling hardware synthesizers or DAWs. ```javascript note("c d e f").midi() s("bd sd hh cp").midi() ``` -------------------------------- ### Spectrum Analysis Visualization Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Display the real-time frequency spectrum of a pattern using the ._spectrum() method. Aids in understanding the harmonic content. ```javascript note("c d e f")._spectrum() ``` -------------------------------- ### Note Sequence Pattern Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/0-strudel-technical-reference.md Creates a melodic sequence of notes using the 'note' function and outputs to Web Audio. ```javascript // Note sequence note("c d e f g a b c") .webaudio() ``` -------------------------------- ### bank(name) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/3-controls-and-parameters.md Selects a sound bank, which is then prepended to the `s` value. This allows for organizing and selecting sounds from specific banks. ```APIDOC ## bank(name) → Pattern ### Description Select sound bank, prepended to the `s` value. ### Parameters #### Path Parameters - **name** (string | Pattern) - Required - Bank name ### Request Example ```javascript s("bd sd").bank("RolandTR909") // equivalent to s("RolandTR909_bd RolandTR909_sd") ``` ``` -------------------------------- ### Select Sound/Sample Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/1-pattern-class.md Controls which sound or sample is played for each event in a pattern. Can accept a string or a pattern of sounds. ```javascript note("c d e").s("sine bd hh") ``` ```javascript s("bd sd [~ bd] sd") ``` -------------------------------- ### Create Patterns from Notation Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/0-strudel-technical-reference.md Define patterns using musical notation for notes, samples, or indices. ```javascript note("c d e f") ``` ```javascript s("bd sd hh") ``` ```javascript n("0 1 2 3") ``` ```javascript pure(value).n(0) ``` -------------------------------- ### Nested Mini Notation Structures Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md Shows how to create deeply nested and mixed nested structures using mini notation for complex pattern arrangements. ```javascript // Deeply nested s("[[bd sd] [hh cp]] sd") ``` ```javascript // Mixed nesting with stacking s("{[bd sd], [hh cp]}") ``` -------------------------------- ### appLeft(patternOfValues) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/1-pattern-class.md Similar to `appBoth`, but retains the timespan structure of the function pattern (the left-hand pattern). ```APIDOC ## appLeft(patternOfValues) ### Description Like `appBoth`, but preserves the timespan structure of the function pattern (left-hand pattern). ### Method `functionPattern.appLeft(valuePattern)` ### Parameters #### Path Parameters - **patternOfValues** (Pattern) - Required - Pattern of values to apply. ### Returns New Pattern with applied values ``` -------------------------------- ### _scope() Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Adds waveform analysis and real-time visualization to the output. ```APIDOC ## _scope() ### Description Adds waveform analysis and real-time visualization to the output. ### Method `_scope()` - Pattern method ### Example ```javascript note("c d e f")._scope() ``` ``` -------------------------------- ### JavaScript Syntax Sugar Transpilation Source: https://github.com/tidalcycles/strudel/wiki/Technical-Manual Demonstrates how Strudel's JavaScript syntax sugar is transpiled into standard JavaScript with mini notation calls. This process adds source location information for real-time highlighting. ```js "c3 [e3 g3]".fast(2) ``` ```js mini('c3 [e3 g3]') .withMiniLocation([1, 0, 0], [1, 11, 11]) // source location .fast(2); ``` -------------------------------- ### Enable/Disable Sample Looping Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Use the 'loop' pattern to control whether a sample should loop during playback. A value of 1 enables looping. ```javascript s("piano").loop(1) ``` -------------------------------- ### Euclidean Rhythm Pattern Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/0-strudel-technical-reference.md Creates a drum pattern based on Euclidean rhythm principles with 5 pulses and 8 steps, outputting to Web Audio. ```javascript // Euclidean rhythm s("bd").euclid(5, 8) .webaudio() ``` -------------------------------- ### Sequencing with Spaces Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md Spaces in mini notation divide a cycle into equal parts, defining the number of events per cycle. ```javascript s("bd sd") // 2 events per cycle s("bd sd hh") // 3 events per cycle s("bd sd hh cp") // 4 events per cycle ``` -------------------------------- ### dough() Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Alias for webaudio output using the superdough synthesis engine. ```APIDOC ## dough() ### Description Alias for webaudio output using the superdough synthesis engine. ### Method `dough()` - Pattern method ### Example ```javascript note("c d e f").dough() ``` ``` -------------------------------- ### Querying Pattern Events Source: https://github.com/tidalcycles/strudel/wiki/Technical-Manual Demonstrates how to query a Strudel pattern for events within a specified time span and format the output for readability. This is used to trigger side effects. ```js seq('c3', ['e3', 'g3']) // <--- Pattern .queryArc(0, 2) // query events within 0 and 2 cycles .map((hap) => hap.showWhole()); // make readable ``` ```js [ '0/1 -> 1/2: c3', // cycle 0 '1/2 -> 3/4: e3', '3/4 -> 1/1: g3', '1/1 -> 3/2: c3', // cycle 1 '3/2 -> 7/4: e3', '7/4 -> 2/1: g3', ]; ``` -------------------------------- ### Select Sound Bank Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/3-controls-and-parameters.md Use the `bank` function to select a sound bank, which prepends the bank name to the `s` value. This allows for organized sound selection. ```javascript s("bd sd").bank("RolandTR909") // equivalent to s("RolandTR909_bd RolandTR909_sd") ``` -------------------------------- ### Using the mini() Function Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/4-mini-notation.md The `mini(...strings)` function parses multiple mini notation strings and concatenates the resulting patterns. ```javascript import { mini } from '@strudel/mini' const pattern = mini("bd sd", "hh cp") ``` -------------------------------- ### Create Chord Progression Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/5-tonal-music-theory.md Generates a chord progression by stacking different chord types and root notes within a specified scale. Suitable for building harmonic sequences. ```javascript stack( note("").chord(""), note(""), note("") ).scale("C:major") ``` -------------------------------- ### Polymetric Structure with Speed Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/0-strudel-technical-reference.md Creates a polymetric structure by stacking two melodic patterns with different speeds, demonstrating complex rhythmic layering. ```javascript // 3 against 4 stack( note("c d e").fast(3), note("f g a b").fast(4) ) ``` -------------------------------- ### Pattern Constructor Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/1-pattern-class.md The core constructor for creating a Pattern. It takes a query function that maps state to haps and an optional number of steps per cycle. ```APIDOC ## Pattern Constructor ### Description Creates a new Pattern instance. ### Parameters #### Path Parameters - **query** (function) - Required - Function mapping a `State` to an array of `Hap` objects. Takes a state object with timing information and returns haps active in that timespan. - **steps** (number/Fraction) - Optional - Default: `undefined` - Number of steps per cycle, used for visual step quantization. **Note**: End users typically create patterns using helper functions like `pure()`, `silence`, `sequence()`, or through mini notation rather than directly instantiating Pattern. ``` -------------------------------- ### postgain(amount) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/3-controls-and-parameters.md Applies a gain multiplier after all effects have been processed. This allows for adjusting the final output level. ```APIDOC ## postgain(amount) → Pattern ### Description Gain applied after all effects. ### Parameters #### Path Parameters - **amount** (number | Pattern) - Required - Postgain multiplier ### Request Example ```javascript s("bd").compressor("-20:20:10:.002:.02").postgain(1.5) ``` ``` -------------------------------- ### Configure Serial Port and Baud Rate Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Set the serial port path (e.g., '/dev/ttyUSB0' or 'COM3') and the baud rate for serial communication. ```javascript import { setSerialPort, setSerialBaudRate } from '@strudel/serial' setSerialPort('/dev/ttyUSB0') // on Linux setSerialPort('COM3') // on Windows setSerialBaudRate(9600) // set baud rate ``` -------------------------------- ### Configure MIDI Output Port Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/8-networking-and-integration.md Set the specific MIDI output port to be used by Strudel. Requires importing the setMidiOut function. ```javascript import { setMidiOut } from '@strudel/midi' setMidiOut(2) // select output port 2 ``` -------------------------------- ### Core Strudel Helper Functions Import Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md Import essential helper functions from the Strudel core library for pattern manipulation, generation, and sequencing. ```javascript import { run, range, rand, euclid, sequence, stack, fastcat, slowcat, pure, silence, choose, flipCoin, sometimes, note, s } from '@strudel/core' ``` -------------------------------- ### Select Chord Voicing Dictionary Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/5-tonal-music-theory.md Selects a specific voicing dictionary to use for generating chord voicings. Aliased as `dict()`. Use this to apply predefined voicing structures. ```javascript note("c").chord("Cm7").dictionary("shell") ``` -------------------------------- ### Apply Post Gain Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/3-controls-and-parameters.md Use the `postgain` function to apply a gain multiplier after all effects have been processed. This can be used for final volume adjustments. ```javascript s("bd").compressor("-20:20:10:.002:.02").postgain(1.5) ``` -------------------------------- ### gain(amount) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/3-controls-and-parameters.md Controls the volume with exponential scaling. A value of 0.5 results in -6dB quieter sound. The default value is 1 (unity gain). ```APIDOC ## gain(amount) → Pattern ### Description Control volume with exponential scaling (0.5 = -6dB quieter). ### Parameters #### Path Parameters - **amount** (number | Pattern) - Required - Gain value (1 = unity) ### Request Example ```javascript s("bd sd").gain("<0.5 1 0.8 0.9>") ``` ``` -------------------------------- ### Euclidean Rhythm Generation Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md Create Euclidean rhythms, which distribute events as evenly as possible within a given number of steps. Supports rotation for rhythmic variation. ```javascript p.euclid(5, 8) // 5 hits in 8 steps p.euclidRot(5, 8, 1) // With rotation ``` -------------------------------- ### Pattern Constructor Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/1-pattern-class.md Instantiates a Pattern object. End users typically use helper functions instead of direct instantiation. ```javascript new Pattern(query, steps = undefined) ``` -------------------------------- ### Create ASCII Graph of Pattern Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/1-pattern-class.md Creates an ASCII graph visualization of pattern values over a specified time range. Useful for a quick visual overview of pattern behavior. ```javascript pattern.graph(0, 2, 8) ``` -------------------------------- ### pure(value) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Creates a pattern from a single value that is active throughout the entire cycle. This can be a sound, a MIDI number, or an object with properties like gain. ```APIDOC ## pure(value) → Pattern Create a pattern from a single value active throughout the cycle. ```javascript pure("bd") pure(60) // MIDI number pure({gain: 0.8}) ``` **Example**: ```javascript pure("bd").fast(4) // bd repeated 4 times ``` ``` -------------------------------- ### appRight(patternOfValues) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/1-pattern-class.md Similar to `appBoth`, but retains the timespan structure of the value pattern (the right-hand pattern). ```APIDOC ## appRight(patternOfValues) ### Description Like `appBoth`, but preserves the timespan structure of the value pattern (right-hand pattern). ### Method `functionPattern.appRight(valuePattern)` ### Parameters #### Path Parameters - **patternOfValues** (Pattern) - Required - Pattern of values to apply. ### Returns New Pattern with applied values ``` -------------------------------- ### Set sample playback speed unit Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/3-controls-and-parameters.md Defines the unit for the `speed` parameter. Use 'c' for cycles, 's' for seconds, or 'r' for rate. ```javascript s("bd").speed(1).unit("c") // stretch to fill cycle ``` -------------------------------- ### Scope Visualization Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Visualize the real-time waveform of a pattern using the ._scope() method. Useful for analyzing audio output. ```javascript note("c d e f")._scope() ``` -------------------------------- ### Fraction Math Operations Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/9-api-cheat-sheet.md Perform fraction arithmetic using the Fraction class. Supports creation from numbers or strings, and basic arithmetic operations. ```javascript import Fraction from '@strudel/core' Fraction(1, 2) // 1/2 Fraction(1, 3) // 1/3 Fraction("1/4") // Parse from string f1.add(f2) // Addition f1.sub(f2) // Subtraction f1.mul(f2) // Multiplication f1.div(f2) // Division ``` -------------------------------- ### s("superpiano") Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Emulates an acoustic piano sound. ```APIDOC ## s("superpiano") ### Description Emulates an acoustic piano sound. ### Method `s("superpiano")` - Pattern method ### Example ```javascript note("c3 e3 g3 c4").s("superpiano") ``` ``` -------------------------------- ### Apply Time-Based Effects Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Configure delay and reverb effects, including send level, time, feedback, amount, and room size. ```javascript s("bd sd") .delay(0.5) // delay send level .delaytime(0.25) // delay time .delayfeedback(0.7) // delay feedback .room(0.8) // reverb amount .size(2) // reverb room size ``` -------------------------------- ### log() Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Logs all current pattern events to the console for debugging purposes. ```APIDOC ## log() ### Description Log all haps to console. ### Request Example ```javascript s("bd sd hh").log() ``` ``` -------------------------------- ### Superpiano Synthesis Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/6-webaudio-and-synthesis.md Generate an acoustic piano emulation. Use for chords or melodic lines. ```javascript note("c3 e3 g3 c4").s("superpiano") ``` -------------------------------- ### Random.int Method Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/2-types-and-datastructures.md Generates random integers within a specified range [min, max]. Useful for selecting discrete values like MIDI notes or indices. ```javascript n(rand.int(0, 7)) ``` -------------------------------- ### take(n, pattern) Source: https://github.com/tidalcycles/strudel/blob/main/_autodocs/7-core-utilities-and-functions.md Takes only the first 'n' elements from each cycle of the given pattern. ```APIDOC ## take(n, pattern) → Pattern Take only first n elements from each cycle. ```javascript take(3, run(8)) // 0 1 2 ``` ```