### Create a minor triad using xen with frequency ratios Source: https://strudel.cc/learn/xen This example demonstrates using `xen` with an array of frequency ratios, achieving the same result as the '31edo' example by manually calculating the ratios. ```javascript i("0 1 2").xen([ Math.pow(2, 0/31), Math.pow(2, 8/31), Math.pow(2, 18/31), ]).piano() ``` -------------------------------- ### Mondo Notation Example Source: https://strudel.cc/learn/mondo-notation This is a basic example of Mondo Notation syntax, demonstrating various operators and functions for pattern generation. ```mondo $ note (c2 # euclid <3 6 3> <8 16>) # *2 # s "sine" # add (note [0 <12 24>]*2) # dec(sine # range .2 2) # room .5 # lpf (sine/3 # range 120 400) # lpenv (rand # range .5 4) # lpq (perlin # range 5 12 # * 2) # dist 1 # fm 4 # fmh 5.01 # fmdecay <.1 .2> # postgain .6 # delay .1 # clip 5 ``` -------------------------------- ### Basic Device Motion Control Example Source: https://strudel.cc/learn/devicemotion This example demonstrates using device tilt and rotation to control a synthesizer's filter cutoff, reverb amount, and volume. It maps gravityY to filter cutoff, rotZ to reverb, and oriX to gain. Ensure motion sensing is enabled before use. ```javascript enableMotion() // Create a simple melody $:n("0 1 3 5") .scale("C:major") // Use tilt (gravity) to control filter .lpf(gravityY.range(200, 2000)) // tilt forward/back for filter cutoff // Use rotation to control effects .room(rotZ.range(0, 0.8)) // rotate device for reverb amount .gain(oriX.range(0.2, 0.8)) // tilt left/right for volume .sound("sawtooth") ``` -------------------------------- ### Mini-Notation Review Examples Source: https://strudel.cc/learn/mini-notation These examples demonstrate various mini-notation features including sequencing, repetition, elongation, and randomness. ```javascript note("*2") ``` ```javascript note("<[g3,b3,e4] [a3,c3,e4] [b3,d3,f#4]>*2") ``` ```javascript note("<[g3,b3,e4]/2 [a3,c3,e4] [b3,d3,f#4]>*2") ``` ```javascript note("<[g3,b3,e4]*2 [a3,c3,e4] [b3,d3,f#4]>*2") ``` ```javascript note("<[g3,b3,e4] _ [a3,c3,e4] [b3,d3,f#4]>*2") ``` ```javascript note("<[g3,b3,e4]@2 [a3,c3,e4] [b3,d3,f#4]>*2") ``` ```javascript note("<[g3,b3,e4]!2 [a3,c3,e4] [b3,d3,f#4]>*2") ``` ```javascript note("<[g3,b3,e4]? [a3,c3,e4] [b3,d3,f#4]>*2") ``` ```javascript note("<[g3|b3|e4] [a3,c3,e4] [b3,d3,f#4]>*2") ``` -------------------------------- ### Apply Distortion with Postgain and Type Source: https://strudel.cc/learn/effects This example demonstrates applying distortion with a specific postgain and distortion type ('diode'). ```javascript s("bd:4*4").bank("tr808").distort("3:0.5:diode") ``` -------------------------------- ### strudel.json Structure Example Source: https://strudel.cc/learn/samples An example of the JSON structure expected for a strudel.json file, including a base path and sample mappings. ```json { "_base": "https://raw.githubusercontent.com/tidalcycles/Dirt-Samples/master/", "bassdrum": "bd/BT0AADA.wav", "snaredrum": "sd/rytm-01-classic.wav", "hihat": "hh27/000_hh27closedhh.wav" } ``` -------------------------------- ### Mondo Playback Control Source: https://strudel.cc/learn/mondo-notation Example showing playback control with 'ply' and nested sequences. ```mondo # ply <1 [1 [2 4]]> ``` -------------------------------- ### Musical Noise Example - Strudel.js Source: https://strudel.cc/learn/synths An example demonstrating the musical application of noise, specifically for hi-hat sounds, by combining drum beats with noise patterns. ```javascript sound("bd*2,*8") .decay(.04).sustain(0)._scope() ``` -------------------------------- ### Multi-line Mini-Notation Example Source: https://strudel.cc/learn/mini-notation Demonstrates the structure of multi-line mini-notation using backticks for complex rhythmic patterns. This is useful for defining intricate sequences of notes and chords. ```javascript note(`< [e5 [b4 c5] d5 [c5 b4]] [a4 [a4 c5] e5 [d5 c5]] [b4 [~ c5] d5 e5] [c5 a4 a4 ~] [[~ d5] [~ f5] a5 [g5 f5]] [e5 [~ c5] e5 [d5 c5]] [b4 [b4 c5] d5 e5] [c5 a4 a4 ~] , [[e2 e3]*4] [[a2 a3]*4] [[g#2 g#3]*2 [e2 e3]*2] [a2 a3 a2 a3 a2 a3 b1 c2] [[d2 d3]*4] [[c2 c3]*4] [[b1 b2]*2 [e2 e3]*2] [[a1 a2]*4] >`) ``` -------------------------------- ### Serve Samples Locally with @strudel/sampler Source: https://strudel.cc/learn/samples Use this command to serve samples from a local directory. Ensure you have NodeJS installed. The sampler auto-generates a strudel.json file. ```bash cd samples npx @strudel/sampler ``` -------------------------------- ### Receive MQTT Messages with mosquitto_sub Source: https://strudel.cc/learn/input-output Example of how to subscribe to an MQTT topic using the mosquitto_sub command-line tool to receive messages sent from Strudel. ```bash mosquitto_sub -h mqtt.eclipseprojects.io -p 1883 -t "/strudel-pattern" ``` -------------------------------- ### Example JSON MQTT Message Source: https://strudel.cc/learn/input-output Illustrates the JSON format of control pattern messages sent over MQTT, showing how Strudel parameters are serialized. ```json {"s":"sax","speed":2} {"s":"sax","speed":2} {"s":"sax","speed":3} {"s":"sax","speed":2} ... ``` -------------------------------- ### Sine Signal Example Source: https://strudel.cc/learn/signals Generates a sine wave and maps it to musical notes within a specified scale. ```javascript n(sine.segment(16).range(0,15)) .scale("C:minor") ``` -------------------------------- ### Mini Notation Highlighting Example Source: https://strudel.cc/learn/visual-feedback Demonstrates how mini notation with double quotes or backticks is highlighted. This is useful for quickly identifying active parts of your notation. ```javascript n("<0 2 1 3 2>*8") .scale("/4:minor:pentatonic") .s("supersaw").lpf(300).lpenv("<4 3 2>*4") ``` -------------------------------- ### Square Signal Example Source: https://strudel.cc/learn/signals Generates a square wave, segments it, and maps the values to musical notes within a minor scale. ```javascript n(square.segment(4).range(0,7)).scale("C:minor") ``` -------------------------------- ### Triangle Signal Example Source: https://strudel.cc/learn/signals Generates a triangle wave, segments it, and maps the values to musical notes within a minor scale. ```javascript n(tri.segment(8).range(0,7)).scale("C:minor") ``` -------------------------------- ### Default Orbit with Reverb and Roomsize Source: https://strudel.cc/learn/effects Example of a pluck sound with a large reverb using the default orbit (1). ```javascript $: s("triangle*4").decay(0.5).n(irand(12)).scale('C minor') .room(1).roomsize(10) ``` -------------------------------- ### Basic Note Declaration Source: https://strudel.cc/learn/code This is a basic example of declaring a note with a specific sound and instrument. It demonstrates the fundamental syntax of calling a function with string arguments. ```javascript note("c a f e").s("piano") ``` -------------------------------- ### Load Custom Wavetable with Strudel Source: https://strudel.cc/learn/synths Use samples prefixed with 'wt_' to load them as wavetables. The 'loop' argument defaults to 1, and 'loopBegin'/'loopEnd' can be used to scan the wavetable. This example demonstrates playing notes with a custom wavetable. ```javascript samples('bubo:waveforms'); note("<[g3,b3,e4]!2 [a3,c3,e4] [b3,d3,f#4]>") .n("<1 2 3 4 5 6 7 8 9 10>/2").room(0.5).size(0.9) .s('wt_flute').velocity(0.25).often(n => n.ply(2)) .release(0.125).decay("<0.1 0.25 0.3 0.4>").sustain(0) .cutoff(2000).cutoff("<1000 2000 4000>").fast(4) ._scope() ``` -------------------------------- ### Tidal Syntax Example Source: https://strudel.cc/learn/strudel-vs-tidal Illustrates Tidal's use of the $ operator and custom operators for pattern manipulation. ```haskell iter 4 $ every 3 (||+ n "10 20") $ (n "0 1 3") # s "triangle" # crush 4 ``` -------------------------------- ### Cosine Signal Example Source: https://strudel.cc/learn/signals Combines sine and cosine signals, segments them, and maps the output to musical notes within a minor scale. ```javascript n(stack(sine,cosine).segment(16).range(0,15)) .scale("C:minor") ``` -------------------------------- ### Registering a Reusable Effect Chain Source: https://strudel.cc/learn/code This example demonstrates how to register a sequence of chained functions as a reusable function. This allows for cleaner and more modular code. ```javascript const effectChain = register('effectChain', (pat) => pat .s("sawtooth") .cutoff(500) //.delay(0.5) .room(0.5) ) note("a3 c#4 e4 a4").effectChain() ``` -------------------------------- ### Configure and Play Custom Csound Instrument Source: https://strudel.cc/learn/csound Configure and play a custom Csound instrument using Strudel's functional API. This example sets scale, note, and instrument. ```javascript "<0 2 [4 6](3,4,2) 3*2>" .off(1/4, add(2)) .off(1/2, add(6)) .scale('D minor') .note() .csound('CoolSynth') ``` -------------------------------- ### Strudel Control Params Example Source: https://strudel.cc/learn/strudel-vs-tidal Shows how Tidal's # operator (shorthand for |>) is a function call in Strudel, demonstrated with note and sample. ```javascript note("c5").s('gtr') ``` -------------------------------- ### Sawtooth Signal Example Source: https://strudel.cc/learn/signals Generates a sawtooth signal and applies it to musical notes. The .clip() method limits the signal's range. ```javascript note("">*8) .clip(saw.slow(2)) ``` ```javascript n(saw.range(0,8).segment(8)) .scale('C major') ``` -------------------------------- ### Apply custom scale using frequency list Source: https://strudel.cc/learn/xen Use the `tune` method with an array of frequencies to define a custom scale. The example uses a list of frequencies and multiplies by 220. ```javascript i("0 1 2 3 4").tune([ 261.6255653006, 302.72962012827, 350.29154279212, 405.32593044476, 469.00678383895, 523.2511306012 ]).mul(220).freq(); ``` -------------------------------- ### Continuous LPF Modulation with Sampling Issue Source: https://strudel.cc/learn/effects This example shows an attempt to continuously modulate a low-pass filter, but it may not produce a smooth LFO due to sampling at note events. ```javascript s("supersaw").lpf(tri.range(100, 5000).slow(2)) ``` -------------------------------- ### Chained Function Example Source: https://strudel.cc/learn/code This snippet showcases chained functions to control various aspects of a sound, such as the notes, instrument, cutoff frequency, and reverb. ```javascript note("a3 c#4 e4 a4") .s("sawtooth") .cutoff(500) //.delay(0.5) .room(0.5) ``` -------------------------------- ### Initialize Hydra in Strudel Source: https://strudel.cc/learn/hydra Call `await initHydra()` at the top of your Strudel script to enable Hydra functionality. This setup is required before using any Hydra functions or patterns. ```javascript await initHydra() // licensed with CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ // by Zach Krall // http://zachkrall.online/ osc(10, 0.9, 300) .color(0.9, 0.7, 0.8) .diff( osc(45, 0.3, 100) .color(0.9, 0.9, 0.9) .rotate(0.18) .pixelate(12) .kaleid() ) .scrollX(10) .colorama() .luma() .repeatX(4) .repeatY(4) .modulate( osc(1, -0.9, 300) ) .scale(2) .out() note("[a,c,e,,b4]/2") .s("sawtooth").vib(2) .lpf(600).lpa(2).lpenv(6) ``` -------------------------------- ### Adjustable Stereo Width with JuxBy Source: https://strudel.cc/learn/effects Jux with adjustable stereo width. 0 is mono, 1 is full stereo. This example uses 'rev' with a pattern for width. ```javascript s("bd lt [~ ht] mt cp ~ bd hh").juxBy("<0 .5 1>/2", rev) ``` -------------------------------- ### Apply multiple scales using xen Source: https://strudel.cc/learn/xen The `xen` function can accept a space-separated string of scale names or EDOs, applying them sequentially. This example uses several EDOs and a named scale. ```javascript i("0 1 2 3 4 5 6 7").xen("<5edo 10edo 15edo hexany15>") ``` -------------------------------- ### Sampler Effect: loopBegin Source: https://strudel.cc/learn/samples The .loopBegin() effect sets the starting point for sample looping. The time parameter must be between the sample's begin and end points. ```tidalcycles s("space").loop(1) .loopBegin("<0 .125 .25>")._scope() ``` -------------------------------- ### Play Imported Samples Source: https://strudel.cc/learn/samples Access and play individual audio samples that have been imported from a local folder. Samples are indexed starting from zero and ordered alphabetically within their respective sound groups. ```javascript s("swoop:0 swoop:1 smash:2") ``` -------------------------------- ### Send MIDI System Real-Time Messages Source: https://strudel.cc/learn/input-output Use `midicmd` to send MIDI system real-time messages like clock, start, stop, and continue. Ensure MIDI is set up initially to avoid unexpected behavior. ```javascript $:stack( midicmd("clock*48,/2").midi('IAC Driver') ) ``` -------------------------------- ### Additive Synthesis - Phases - Strudel.js Source: https://strudel.cc/learn/synths Control the phase of each harmonic using the `phases` function, in conjunction with `partials`, to add depth and complexity to synthesized sounds. This example uses randomized partials and phases. ```javascript s("saw").seg(16).n(irand(12)).scale("F1:minor") .penv(48).panchor(0).pdec(0.05) .delay(0.25).room(0.25) .compressor(-20).vib(0.3) .partials(randL(200)) .phases(randL(200)) ``` -------------------------------- ### Nudge pattern earlier Source: https://strudel.cc/learn/time-modifiers Nudges a pattern to start earlier in time. Equivalent to Tidal's '<~' operator. Use when you want to shift the timing of events slightly before their scheduled start. ```javascript "bd ~ ".stack("hh ~ ".early(.1)).s() ``` -------------------------------- ### Load Samples from GitHub Repository Source: https://strudel.cc/learn/samples Utilize the 'samples' function with a GitHub shortcut to load audio samples directly from a repository. This method assumes a strudel.json file exists at the root of the specified repository. ```javascript samples('github:tidalcycles/dirt-samples') ``` ```javascript s("bd sd bd sd,hh*16") ``` -------------------------------- ### Nudge pattern later Source: https://strudel.cc/learn/time-modifiers Nudges a pattern to start later in time. Equivalent to Tidal's '~>' operator. Use when you want to shift the timing of events slightly after their scheduled start. ```javascript "bd ~ ".stack("hh ~ ".late(.1)).s() ``` -------------------------------- ### Mondo REPL Usage Source: https://strudel.cc/learn/mondo-notation Demonstrates how to use Mondo Notation directly within the REPL environment. ```mondo mondo`s hh*8` ``` -------------------------------- ### Utilize ZZFX Synthesizer with All Parameters Source: https://strudel.cc/learn/synths This snippet demonstrates the full range of ZZFX synthesizer parameters, including envelope settings, pitch modulation, and effects like bitcrushing and delay. It also shows how to use different ZZFX waveforms. ```javascript note("c2 eb2 f2 g2") // also supports freq .s("{z_sawtooth z_tan z_noise z_sine z_square}%4") .zrand(0) // randomization // zzfx envelope .attack(0.001) .decay(0.1) .sustain(.8) .release(.1) // special zzfx params .curve(1) // waveshape 1-3 .slide(0) // +/- pitch slide .deltaSlide(0) // +/- pitch slide (?) .noise(0) // make it dirty .zmod(0) // fm speed .zcrush(0) // bit crush 0 - 1 .zdelay(0) // simple delay .pitchJump(0) // +/- pitch change after pitchJumpTime .pitchJumpTime(0) // >0 time after pitchJump is applied .lfo(0) // >0 resets slide + pitchJump + sets tremolo speed .tremolo(0.5) // 0-1 lfo volume modulation amount //.duration(.2) // overwrite strudel event duration //.gain(1) // change volume ._scope() // vizualise waveform (not zzfx related) ``` -------------------------------- ### Mondo Decay Function Source: https://strudel.cc/learn/mondo-notation Example using the 'dec' function with a complex pattern. ```mondo # dec (<.02 .05>*2 # add (saw/8 # range 0 1)) ``` -------------------------------- ### Mondo Speed Modification Source: https://strudel.cc/learn/mondo-notation Example of modifying playback speed using 'speed' in Mondo Notation. ```mondo $ s oh*4 # press # bank tr909 # speed.8 ``` -------------------------------- ### Swing Shorthand Example Source: https://strudel.cc/learn/time-modifiers Uses the swing shorthand for swingBy with a subdivision. This is equivalent to calling swingBy with a fraction. ```javascript s("hh*8").swing(4) ``` -------------------------------- ### Use inhabit with a string pattern Source: https://strudel.cc/learn/conditional-modifiers Illustrates using inhabit with a string pattern and a lookup object. The result is slowed down. ```javascript s("a@2 [a b] a" .inhabit({a: "bd(3,8)", b: "sd sd"})) .slow(4) ``` -------------------------------- ### Reverb Lowpass Frequency Source: https://strudel.cc/learn/effects Reverb lowpass starting frequency in hertz. Recalculates reverb, so change sparsely. ```APIDOC ## roomlp ### Description Reverb lowpass starting frequency (in hertz). When this property is changed, the reverb will be recaculated, so only change this sparsely.. ### Synonyms `rlp` ### Parameters #### Path Parameters - **frequency** (number) - Required - between 0 and 20000hz ### Request Example ``` s("bd sd [~ bd] sd").room(0.5).rlp(10000) ``` ``` s("bd sd [~ bd] sd").room(0.5).rlp(5000) ``` ``` -------------------------------- ### Set root note with getFreq and tune Source: https://strudel.cc/learn/xen Configure a scale like 'tranh3' and set the root note using `getFreq('c3')`. Adjusts frequency output with `.freq().clip(.5).room(1)`. ```javascript i("4 8 9 10 - - 5 7 9 11 - -").tune("tranh3") .mul(getFreq('c3')) .freq().clip(.5).room(1) ``` -------------------------------- ### Import Local Sounds Folder Source: https://strudel.cc/learn/samples Import audio samples from a local folder into Strudel.cc's REPL. The 'sounds' tab provides an 'import-sounds' option to select a folder containing audio files and subfolders. ```bash └─ samples ├─ swoop │ ├─ swoopshort.wav │ ├─ swooplong.wav │ └─ swooptight.wav └─ smash ├─ smashhigh.wav ├─ smashlow.wav └─ smashmiddle.wav ``` -------------------------------- ### midi(outputName?, options?) Source: https://strudel.cc/learn/input-output Connects to a MIDI output device or uses an internal MIDI connection. If no outputName is provided, it defaults to the first available MIDI output. ```APIDOC ## midi(outputName?, options?) Connects to a MIDI output device or uses an internal MIDI connection. If no outputName is provided, it defaults to the first available MIDI output. ### Example ```javascript chord("").voicing().midi('IAC Driver') ``` ### Options The `.midi()` function accepts an options object with the following properties: | Option | Type | Default | Description | |--------------|---------|---------|-----------------------------------------------------------------------------| | isController | boolean | false | When true, disables sending note messages. Useful for MIDI controllers. | | latencyMs | number | 34 | Latency in milliseconds to align MIDI with audio engine. | | noteOffsetMs | number | 10 | Offset in milliseconds for note-off messages to prevent glitching. | | midichannel | number | 1 | Default MIDI channel (1-16). | | velocity | number | 0.9 | Default note velocity (0-1). | | gain | number | 1 | Default gain multiplier for velocity (0-1). | | midimap | string | 'default' | Name of MIDI mapping to use for control changes. | | midiport | string/number | - | MIDI device name or index. | ### Example with Options ```javascript note("d e c a f").midi('IAC Driver', { isController: true, midimap: 'default'}) ``` ``` -------------------------------- ### Load Samples from Local Server Source: https://strudel.cc/learn/samples Load samples served from a local file server using the samples function with a URL. This method is convenient for managing larger sample libraries. ```javascript samples('http://localhost:5432/'); n("<0 1 2>").s("swoop smash") ``` -------------------------------- ### Apply Jux Effect with Press Source: https://strudel.cc/learn/effects Applies a function to the right-hand channel only, creating stereo effects. This example uses the 'press' function. ```javascript s("bd lt [~ ht] mt cp ~ bd hh").jux(press) ``` -------------------------------- ### Apply Jux Effect with Reverse Source: https://strudel.cc/learn/effects Applies a function to the right-hand channel only, creating stereo effects. This example uses the 'rev' function. ```javascript s("bd lt [~ ht] mt cp ~ bd hh").jux(rev) ``` -------------------------------- ### Initialize Gamepad Source: https://strudel.cc/learn/input-devices Initializes a gamepad object. An optional index parameter can be provided to specify which gamepad to connect to, defaulting to the first one (index 0). ```javascript // Initialize gamepad (optional index parameter, defaults to 0) const gp = gamepad(0) ``` ```javascript const pad1 = gamepad(0); // First gamepad const pad2 = gamepad(1); // Second gamepad ``` -------------------------------- ### Mondo Lambda Functions Source: https://strudel.cc/learn/mondo-notation Demonstrates the use of lambda functions in Mondo Notation, shortening the syntax for passing functions as arguments. ```mondo n 0..7 # scale C:minor # sometimes (# dec .1) ``` ```mondo n 0..7 # scale C:minor # sometimes (# dec .1 # jux rev) ``` -------------------------------- ### Mini Notation Highlighting with Color Source: https://strudel.cc/learn/visual-feedback Shows how to change the color of highlighted mini notation and even pattern the colors. ```javascript n("<0 2 1 3 2>*8") .scale("/4:minor:pentatonic") .s("supersaw").lpf(300).lpenv("<4 3 2>*4") .color("cyan magenta") ``` -------------------------------- ### Load Samples from File URLs Source: https://strudel.cc/learn/samples Assigns names to specific audio files on a server and makes them available for use in the `s` function. Supports loading single files or lists of files for a given sample name. ```javascript samples({ bassdrum: 'bd/BT0AADA.wav', hihat: 'hh27/000_hh27closedhh.wav', snaredrum: ['sd/rytm-01-classic.wav', 'sd/rytm-00-hard.wav'], }, 'https://raw.githubusercontent.com/tidalcycles/Dirt-Samples/master/'); s("bassdrum snaredrum:0 bassdrum snaredrum:1, hihat*16") ``` -------------------------------- ### Line Comment Example Source: https://strudel.cc/learn/code This shows how to use line comments (`//`) to temporarily disable a function call. This is useful for debugging or experimenting with code. ```javascript //.delay(0.5) ``` -------------------------------- ### Use inhabit with a lookup object Source: https://strudel.cc/learn/conditional-modifiers Shows how to use the inhabit function with a lookup object. Cycles are squeezed into the target pattern. ```javascript let a = s("bd(3,8)") let b = s("cp sd") "".inhabit({ a, b }) ``` -------------------------------- ### Reversed Function Call Source: https://strudel.cc/learn/code This example demonstrates that reversing the order of function calls can change the behavior, potentially only executing the first function in the sequence. ```javascript s("piano").note("c a f e") ``` -------------------------------- ### Set Reverb Lowpass Frequency Source: https://strudel.cc/learn/effects Sets the starting frequency for the reverb's lowpass filter in hertz. Recalculates the reverb, so use sparingly. ```javascript s("bd sd [~ bd] sd").room(0.5).rlp(10000) ``` ```javascript s("bd sd [~ bd] sd").room(0.5).rlp(5000) ``` -------------------------------- ### Load .orc File and Play Multiple CSound Instruments Source: https://strudel.cc/learn/csound Load a CSound .orc file and play a sequence of notes using various instruments defined within the file. This demonstrates accessing a library of sounds. ```javascript // livecode.orc by Steven Yi await loadOrc('github:kunstmusik/csound-live-code/master/livecode.orc') note("c a f e").csound(cat( "Sub1", // Substractive Synth, 3osc "Sub2", // Subtractive Synth, two saws, fifth freq apart "Sub3", // Subtractive Synth, three detuned saws, swells in "Sub4", // Subtractive Synth, detuned square/saw, stabby. Nice as a lead in octave 2, nicely grungy in octave -2, -1 "Sub5", // Subtractive Synth, detuned square/triangle "Sub6", // Subtractive Synth, saw, K35 filters "Sub7", // Subtractive Synth, saw + tri, K35 filters "Sub8", // Subtractive Synth, square + saw + tri, diode ladder filter "SynBrass", // SynthBrass subtractive synth "SynHarp", // Synth Harp subtracitve Synth "SSaw", // SuperSaw sound using 9 bandlimited saws (3 sets of detuned saws at octaves) "Mode1", // Modal Synthesis Instrument: Percussive/organ-y sound "Plk", // Pluck sound using impulses, noise, and waveguides "Organ1", // Wavetable Organ sound using additive synthesis "Organ2", // Organ sound based on M1 Organ 2 patch "Organ3", // Wavetable Organ using Flute 8' and Flute 4', wavetable based on Claribel Flute http://www.pykett.org.uk/the_tonal_structure_of_organ_flutes.htm "Bass", // Subtractive Bass sound "ms20_bass", // MS20-style Bass Sound "VoxHumana", // VoxHumana Patch "FM1", // FM 3:1 C:M ratio, 2->0.025 index, nice for bass "Noi", // Filtered noise, exponential envelope "Wobble", // Wobble patched based on Jacob Joaquin's "Tempo-Synced Wobble Bass" "Sine", // Simple Sine-wave instrument with exponential envelope "Square", // Simple Square-wave instrument with exponential envelope "Saw", // Simple Sawtooth-wave instrument with exponential envelope "Squine1", // Squinewave Synth, 2 osc "Form1", // Formant Synth, buzz source, soprano ah formants "Mono", // Monophone synth using sawtooth wave and 4pole lpf. Use "start("Mono") to run the monosynth, then use MonoNote instrument to play the instrument. "MonoNote", // Note playing instrument for Mono synth. Be careful to use this and not try to create multiple Mono instruments! "Click", // Bandpass-filtered impulse glitchy click sound. p4 = center frequency (e.g., 3000, 6000) "NoiSaw", // Highpass-filtered noise+saw sound. Use NoiSaw.cut channel to adjust cutoff. "Clap", // Modified clap instrument by Istvan Varga (clap1.orc) "BD", // Bass Drum - From Iain McCurdy's TR-808.csd "SD", // Snare Drum - From Iain McCurdy's TR-808.csd "OHH", // Open High Hat - From Iain McCurdy's TR-808.csd "CHH", // Closed High Hat - From Iain McCurdy's TR-808.csd "HiTom", // High Tom - From Iain McCurdy's TR-808.csd "MidTom", // Mid Tom - From Iain McCurdy's TR-808.csd "LowTom", // Low Tom - From Iain McCurdy's TR-808.csd "Cymbal", // Cymbal - From Iain McCurdy's TR-808.csd "Rimshot", // Rimshot - From Iain McCurdy's TR-808.csd "Claves", // Claves - From Iain McCurdy's TR-808.csd "Cowbell", // Cowbell - From Iain McCurdy's TR-808.csd "Maraca", // Maraca - from Iain McCurdy's TR-808.csd "HiConga", // High Conga - From Iain McCurdy's TR-808.csd "MidConga", // Mid Conga - From Iain McCurdy's TR-808.csd "LowConga" // Low Conga - From Iain McCurdy's TR-808.csd )) ``` -------------------------------- ### Generate strudel.json with @strudel/sampler Source: https://strudel.cc/learn/samples Use the @strudel/sampler command-line tool to generate a strudel.json file. This file is essential for organizing and referencing your audio samples. ```bash npx --yes @strudel/sampler --json > strudel.json ``` -------------------------------- ### Delay Feedback Source: https://strudel.cc/learn/effects Sets the level of the signal that is fed back into the delay. Caution: Values >= 1 will result in a signal that gets louder and louder! ```APIDOC ## delayfeedback ### Description Sets the level of the signal that is fed back into the delay. Caution: Values >= 1 will result in a signal that gets louder and louder! Don't do it ### Synonyms `delayfb, dfb` ### Parameters #### Path Parameters - **feedback** (number|Pattern) - Required - between 0 and 1 ### Request Example ``` s("bd").delay(.25).delayfeedback("<.25 .5 .75 1>") ``` ``` -------------------------------- ### Enable Audio Detection with `initHydra` Source: https://strudel.cc/learn/hydra Initialize Hydra with `{detectAudio:true}` to capture and utilize audio input within Strudel. This allows audio data, like FFT, to control visual parameters such as scrolling. ```javascript await initHydra({detectAudio:true}) let pattern = "<3 4 5 [6 7]*2>" shape(H(pattern)).repeat() .scrollY( (()=> a.fft[0]*.25) ) .add(src(o0).color(.71 ).scrollX(.005),.95) .out(o0) n(pattern).scale("A:minor").piano().room(1) ``` -------------------------------- ### Silence with `mask` Source: https://strudel.cc/learn/conditional-modifiers The `mask` modifier silences a pattern when the mask condition is met (0 or '~'). This example masks specific notes within a sequence. ```javascript note("c [eb,g] d [eb,g]").mask("<1 [0 1]>") ``` -------------------------------- ### Define Custom Csound Instrument Source: https://strudel.cc/learn/csound Use `loadCsound` to define a custom Csound instrument. This example defines a 'CoolSynth' instrument with oscillators, filters, and envelopes. ```javascript await loadCsound` instr CoolSynth iduration = p3 ifreq = p4 igain = p5 ioct = octcps(ifreq) kpwm = oscili(.05, 8) asig = vco2(igain, ifreq, 4, .5 + kpwm) asig += vco2(igain, ifreq * 2) idepth = 2 acut = transegr:a(0, .005, 0, idepth, .06, -4.2, 0.001, .01, -4.2, 0) ; filter envelope asig = zdf_2pole(asig, cpsoct(ioct + acut + 2), 0.5) iattack = .01 isustain = .5 idecay = .1 irelease = .1 asig *= linsegr:a(0, iattack, 1, idecay, isustain, iduration, isustain, irelease, 0) out(asig, asig) endin` ``` -------------------------------- ### Comparing fastcat and stepcat Source: https://strudel.cc/learn/stepwise Demonstrates the difference between `fastcat` (squashes cycles) and `stepcat` (evenly distributes steps) when combining patterns. ```javascript fastcat("bd hh hh", "bd hh hh cp hh").sound() ``` ```javascript stepcat("bd hh hh", "bd hh hh cp hh").sound() ``` -------------------------------- ### Iterate Subdivisions of a Pattern Source: https://strudel.cc/learn/time-modifiers Divides a pattern into a specified number of subdivisions and plays them in order, incrementing the starting subdivision each cycle. The pattern wraps around. ```javascript note("0 1 2 3".scale('A minor')).iter(4) ``` -------------------------------- ### Load Samples from strudel.json Source: https://strudel.cc/learn/samples Loads a sample map from a strudel.json file hosted online. The file can define a base path using the `_base` key and map sample names to their respective audio files. ```javascript samples('https://raw.githubusercontent.com/tidalcycles/Dirt-Samples/master/strudel.json') s("bd sd bd sd,hh*16") ``` -------------------------------- ### Set Reverb Level and Size with Mininotation Source: https://strudel.cc/learn/effects Applies reverb using mininotation, specifying both the level and the room size. ```javascript s("bd sd [~ bd] sd").room("<0.9:1 0.9:4>") ``` -------------------------------- ### Apply Conditional Effects with `all` and `when` in Strudel Source: https://strudel.cc/learn/faq Use `all` and `when` to apply effects conditionally across all patterns. This example applies a low-pass filter sweep every 8 cycles. ```strudel all(x=>x.when("<0!7 1>", x=>x.lpf(saw.range(200, 2000)))) ``` -------------------------------- ### Send a Simple Pattern to MQTT Source: https://strudel.cc/learn/input-output Use the `.mqtt()` method to send a basic string pattern to a specified MQTT topic. Ensure your MQTT broker is configured for secure WebSocket connections. ```javascript "hello world" .mqtt(undefined, // username (undefined for open/public servers) undefined, // password '/strudel-pattern', // mqtt 'topic' 'wss://mqtt.eclipseprojects.io:443/mqtt', // MQTT server address 'mystrudel', // MQTT client id - randomly generated if not supplied 0 // latency / delay before sending messages (0 = no delay) ) ``` -------------------------------- ### Query Samples with Shabda Source: https://strudel.cc/learn/samples Use the samples function with Shabda to query freesound.org by sample name and ID. The output is then processed by n() and s() functions. ```tidalcycles samples('shabda:bass:4,hihat:4,rimshot:2') ``` ```tidalcycles n("0 1 2 3 0 1 2 3").s('bass') ``` ```tidalcycles n("0 1*2 2 3*2").s('hihat').clip(1) ``` ```tidalcycles n("~ 0 ~ 1 ~ 0 0 1").s('rimshot') ``` -------------------------------- ### Euclidean Rhythm: Varying Offset Source: https://strudel.cc/learn/mini-notation Shows the impact of the optional 'offset' parameter on the starting position of beats in Euclidean rhythms, using a secondary rhythm for comparison. ```javascript s("bd(3,8,0), hh cp") ``` ```javascript s("bd(3,8,3), hh cp") ``` ```javascript s("bd(3,8,5), hh cp") ``` -------------------------------- ### Play Chords with ',' Source: https://strudel.cc/learn/mini-notation Separate notes with commas within brackets to play them as a chord. This allows for simultaneous notes. ```javascript note("[g3,b3,e4]") ``` ```javascript note("g3,b3,e4") ``` -------------------------------- ### Combine tune with polyrhythm and fmap Source: https://strudel.cc/learn/xen Apply the 'iraq' tuning with polyrhythmic patterns and dynamic base notes using `fmap`. Includes clip, room, and rfade effects. ```javascript i("<[0 3 1 -] [-1 4 2 8]> ~ ~,<-4 -5>".add(4)) .tune("iraq") .mul("".fmap(getFreq)) .freq().clip(.5).room(1).rfade(9) ``` -------------------------------- ### Apply Jux Effect with Iteration Source: https://strudel.cc/learn/effects Applies a function to the right-hand channel only, creating stereo effects. This example uses 'iter(4)' to repeat the function four times. ```javascript s("bd lt [~ ht] mt cp ~ bd hh").jux(iter(4)) ``` -------------------------------- ### Load and Play CSound Instrument from .orc File Source: https://strudel.cc/learn/csound Load a CSound .orc file from a URL and play a specific instrument. Use this to integrate existing CSound instruments into your Strudel project. ```javascript await loadOrc('github:kunstmusik/csound-live-code/master/livecode.orc') note("c a f e").csound('FM1') ``` -------------------------------- ### FM Synthesis Source: https://strudel.cc/learn/synths FM Synthesis alters timbre by rapidly changing the frequency of a basic waveform. It can be used with any waveform, but examples often use the default triangle wave. ```APIDOC ## FM Synthesis ### Description FM Synthesis is a technique that changes the frequency of a basic waveform rapidly to alter the timbre. You can use fm with any of the above waveforms, although the below examples all use the default triangle wave. ``` -------------------------------- ### Step counting with sub-patterns Source: https://strudel.cc/learn/stepwise Illustrates how sub-patterns are counted as single steps by default, and how marking a different metrical level with `^` changes the step count. ```javascript "a [b c] d e" ``` ```javascript "[^b c]" ``` -------------------------------- ### Invalid Note Declarations Source: https://strudel.cc/learn/code These examples show invalid syntax for note declarations. They illustrate that arguments must be enclosed in quotes and that function calls require specific delimiters. ```javascript note(c a f e).s(piano) ``` ```javascript note("c a f e")s("piano") ``` ```javascript note["c a f e"].s{"piano"} ``` -------------------------------- ### Apply Tremolo Sync with Phase Offset Source: https://strudel.cc/learn/effects Adjusts the phase of the amplitude modulation waveform. `tremolophase` takes an offset in cycles to shift the modulation's starting point. ```strudel note("{f a c e}%16").s("sawtooth").tremsync(4).tremolophase("<0 .25 .66>") ``` -------------------------------- ### Choose from a list of elements Source: https://strudel.cc/learn/random-modifiers Use `choose` to randomly select an element from a provided list or pattern. This is useful for varying musical elements like instrument sounds. ```javascript note("c2 g2!2 d2 f1").s(choose("sine", "triangle", "bd:6")) ``` -------------------------------- ### Complex Rhythmic Pattern with Euclidean Notation Source: https://strudel.cc/learn/mini-notation Demonstrates creating a more complex musical pattern using multiple notes with Euclidean rhythm subdivisions. ```javascript note("e5(2,8) b4(3,8) d5(2,8) c5(3,8)").slow(2) ``` -------------------------------- ### Apply function every n cycles from the first Source: https://strudel.cc/learn/conditional-modifiers Use `firstOf` to apply a function every n cycles, starting from the first cycle. The function `func` is applied to the pattern. ```javascript note("c3 d3 e3 g3").firstOf(4, x=>x.rev()) ``` -------------------------------- ### Single-line Mini-Notation with Spaces Source: https://strudel.cc/learn/mini-notation Shows how to represent multiple notes within a single cycle by separating them with spaces. Each space-separated note becomes an event, and their duration adjusts to fit the cycle's tempo. ```javascript note("c e g b") ``` -------------------------------- ### Apply function every n cycles from the last Source: https://strudel.cc/learn/conditional-modifiers Use `lastOf` to apply a function every n cycles, starting from the last cycle. The function `func` is applied to the pattern. ```javascript note("c3 d3 e3 g3").lastOf(4, x=>x.rev()) ``` -------------------------------- ### Invert Binary Pattern with `invert` Source: https://strudel.cc/learn/conditional-modifiers The `invert` modifier (or its synonym `inv`) swaps 1s and 0s in a binary pattern. This example applies inversion to the last four elements of a structured pattern. ```javascript s("bd").struct("1 0 0 1 0 0 1 0".lastOf(4, invert)) ``` -------------------------------- ### Configure MIDI Output Options Source: https://strudel.cc/learn/input-output Configure MIDI output with options such as disabling note messages for controllers, setting latency, or specifying a MIDI mapping. ```javascript $: note("d e c a f").midi('IAC Driver', { isController: true, midimap: 'default'}) ``` -------------------------------- ### Euclidean Rhythm Notation vs. Full Notation Source: https://strudel.cc/learn/mini-notation Compares the concise Euclidean rhythm notation with its expanded, full notation equivalent. ```javascript s("bd ~ ~ bd ~ ~ bd ~") ``` ```javascript s("bd(3,8,0)") ``` -------------------------------- ### Progressively grow a pattern with grow Source: https://strudel.cc/learn/stepwise Expands a pattern by a specified number of steps from the start (positive) or end (negative), repeating the process. Use for creating gradually building or expanding rhythmic effects. ```javascript "tha dhi thom nam".grow("1").sound() .bank("mridangam") ``` ```javascript "tha dhi thom nam".grow("-1").sound() .bank("mridangam") ``` ```javascript "tha dhi thom nam".grow("1 -1").sound().bank("mridangam").pace(4) ``` ```javascript note("0 1 2 3 4 5 6 7".scale("C:ritusen")).sound("folkharp") .grow("1 -1").pace(8) ``` -------------------------------- ### Mondo Chaining Functions Locally Source: https://strudel.cc/learn/mondo-notation Shows how to apply a function to a single element within a sequence by wrapping it in round parentheses. ```mondo s [bd hh bd (cp # delay .6)] # bank tr909 ``` ```javascript s(seq("bd", "hh", "bd", "cp".delay(.6))).bank('tr909') ``` -------------------------------- ### Progressively shrink a pattern with shrink Source: https://strudel.cc/learn/stepwise Reduces a pattern by a specified number of steps from the start (positive) or end (negative), repeating the process. Use for creating gradually fading or diminishing rhythmic effects. ```javascript "tha dhi thom nam".shrink("1").sound() .bank("mridangam") ``` ```javascript "tha dhi thom nam".shrink("-1").sound() .bank("mridangam") ``` ```javascript "tha dhi thom nam".shrink("1 -1").sound().bank("mridangam").pace(4) ``` ```javascript note("0 1 2 3 4 5 6 7".scale("C:ritusen")).sound("folkharp") .shrink("1 -1").pace(8) ``` -------------------------------- ### Target LFO using FX Index Source: https://strudel.cc/learn/lfo When using FX to reorder effects, LFOs can be targeted by their FX index instead of being defined within the FX chain. The FX index starts from 0. ```javascript s("saw").FX( distort(3), gain(0.3), // this has the fx index 1 lpf(400) ).lfo({s: 16, dr:2, c:"gain", fxi: 1}) ```