### Serve Samples from Disk with @strudel/sampler Source: https://strudel.cc/learn/samples Use this command to start a local file server for your samples. Ensure you have NodeJS installed. The sampler automatically generates a strudel.json file. ```bash cd samples npx @strudel/sampler ``` -------------------------------- ### Pattern Playback Example Source: https://strudel.cc/learn/mondo-notation Example of playing a pattern with a specific structure using Mondo Notation. ```mondo # ply <1 [1 [2 4]]> ``` -------------------------------- ### Minimal Sawtooth Synth Example Source: https://strudel.cc/technical-manual/sounds This example demonstrates registering a 'mysaw' sound using a sawtooth oscillator and a gain node. It shows how to create, connect, and manage the audio nodes, and how to return the necessary `node` and `stop` functions. ```typescript registerSound( 'mysaw', (time, value, onended) => { let { freq } = value; // destructure control params const ctx = getAudioContext(); // create oscillator const o = new OscillatorNode(ctx, { type: 'sawtooth', frequency: Number(freq) }); o.start(time); // add gain node to level down osc const g = new GainNode(ctx, { gain: 0.3 }); // connect osc to gain const node = o.connect(g); // this function can be called from outside to stop the sound const stop = (time) => o.stop(time); // ended will be fired when stop has been fired o.addEventListener('ended', () => { o.disconnect(); g.disconnect(); onended(); }); return { node, stop }; }, { type: 'synth' }, ); // use the sound freq("220 440 330").s('mysaw'); ``` -------------------------------- ### Basic Mondo Notation Example Source: https://strudel.cc/learn/mondo-notation This is a fundamental example demonstrating the syntax of Mondo Notation for defining musical patterns and effects. ```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 ``` -------------------------------- ### Add Numbers/Notes with add (Table Example) Source: https://strudel.cc/workshop/pattern-effects This example shows the `add` function for combining notes or numbers, as presented in a table. ```haskell n("0 2 4 6 ~ 7 9 5".add("<0 1 2 1>")).scale("C:minor") ``` -------------------------------- ### Utilize ZZFX Synth Parameters Source: https://strudel.cc/learn/synths Comprehensive example showing all 20 parameters available for the ZZFX synth engine. ```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) ``` -------------------------------- ### Mini-Notation Review Examples Source: https://strudel.cc/learn/mini-notation A collection of examples demonstrating various mini-notation features including grouping, division, multiplication, spacing, weighting, replication, 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") ``` -------------------------------- ### Juxtapose with rev (Table Example) Source: https://strudel.cc/workshop/pattern-effects This example demonstrates the `jux` function combined with `rev` for a stereo effect, as shown in a table format. ```haskell n("0 2 4 6 ~ 7 9 5").scale("C:minor").jux(rev) ``` -------------------------------- ### Complex Additive Synthesis Example Source: https://strudel.cc/learn/synths An advanced example demonstrating additive synthesis using `partials` and `phases` with random values, along with other effects like delay and compression. ```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)) ``` -------------------------------- ### Mini Notation AST Example Source: https://strudel.cc/technical-manual/repl An example Abstract Syntax Tree (AST) generated from Strudel's mini notation. ```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 } } } ] }, } ] } ``` -------------------------------- ### Strudel pattern examples Source: https://strudel.cc/learn/hydra Standalone Strudel pattern and synthesis examples. ```javascript $: s("bd*4,[hh:0:<.5 1>]*8,~ rim").bank("RolandTR909").speed(.9) ``` ```javascript $: note("[>>]*3").s("sawtooth") ``` ```javascript .room(.75).sometimes(add(note(12))).clip(.3) .lpa(.05).lpenv(-4).lpf(2000).lpq(8).ftype('24db') ``` ```javascript all(x=>x.fft(4).scope({pos:0,smear:.95})) ``` -------------------------------- ### Musical Noise Example for Hi-Hats Source: https://strudel.cc/learn/synths An example demonstrating the musical application of noise, specifically for creating hi-hat sounds by layering noise with a bass drum. ```javascript sound("bd*2,*8") .decay(.04).sustain(0)._scope() ``` -------------------------------- ### strudel.json File Structure Example Source: https://strudel.cc/learn/samples An example of the JSON structure expected in a strudel.json file, including a base path and sample definitions. ```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" } ``` -------------------------------- ### Subscribe to MQTT Topic (Command Line) Source: https://strudel.cc/learn/input-output This example shows 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" ``` -------------------------------- ### Mondo Notation Sequence Example Source: https://strudel.cc/learn/mondo-notation An example showcasing the use of brackets for defining sequences in Mondo Notation: `[]` for 1-cycle, `<>` for multi-cycle, and `{}` for stepped sequences. ```mondo 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 ~] > ``` -------------------------------- ### Configure FM Envelope Parameters Source: https://strudel.cc/learn/synths Examples demonstrating how to control FM envelope characteristics using fmattack, fmdecay, fmsustain, and fmenv. ```javascript note("c e g b g e") .fm(4) .fmattack("<0 .05 .1 .2>") ._scope() ``` ```javascript note("c e g b g e") .fm(4) .fmdecay("<.01 .05 .1 .2>") .fmsustain(.4) ._scope() ``` ```javascript note("c e g b g e") .fm(4) .fmdecay(.1) .fmsustain("<1 .75 .5 0>") ._scope() ``` ```javascript note("c e g b g e") .fm(4) .fmdecay(.2) .fmsustain(0) .fmenv("") ._scope() ``` -------------------------------- ### Invalid Syntax Examples Source: https://strudel.cc/learn/code Examples of incorrect syntax that will not execute in the Strudel environment. ```javascript note(c a f e).s(piano) ``` ```javascript note("c a f e")s("piano") ``` ```javascript note["c a f e"].s{"piano"} ``` -------------------------------- ### Load Samples from Local Server Source: https://strudel.cc/learn/samples Load samples from a local server using the samples() function. This example plays a 'swoop smash' sound. ```javascript samples('http://localhost:5432/'); n("<0 1 2>").s("swoop smash") ``` -------------------------------- ### Square Signal Example Source: https://strudel.cc/learn/signals Creates a square signal, segments it, and scales to C minor. ```javascript n(square.segment(4).range(0,7)).scale("C:minor") ``` -------------------------------- ### Complex Pattern Example Source: https://strudel.cc/learn/mini-notation A multi-line example demonstrating the use of backticks for complex, multi-layered patterns. ```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] >`) ``` -------------------------------- ### Create Backing Track with Voicings and Root Notes Source: https://strudel.cc/learn/tonal This example creates a backing track by layering voicings for the left hand and root notes for the right hand, using `layer`, `voicings`, `struct`, `rootNotes`, `note`, `s`, and `cutoff`. ```javascript "*2".layer( x => x.voicings('lefthand').struct("[~ x]*2").note(), x => x.rootNotes(2).note().s('sawtooth').cutoff(800) ) ``` -------------------------------- ### Jazz Blues Example with Multiple Voicing Controls Source: https://strudel.cc/understand/voicings An example demonstrating a Jazz Blues progression in F, utilizing `chord`, `voicing`, `n`, `set`, `mode`, and `dec` to create a complex musical arrangement with melody, chords, and bassline. ```javascript let chords = chord(`< F7 Bb7 F7 [Cm7 F7] Bb7 Bo F7 [Am7 D7] Gm7 C7 [F7 D7] [Gm7 C7] >`); $: n("7 8 [10 9] 8").set(chords).voicing().dec(.2) ``` ```javascript $: chords.struct("- x - x").voicing().room(.5) ``` ```javascript $: n("0 - 1 - ").set(chords).mode("root:g2").voicing() ``` -------------------------------- ### Speed Up Events with ply (Table Example) Source: https://strudel.cc/workshop/pattern-effects This example illustrates the `ply` function for repeating events, as found in a table. ```haskell s("bd sd [~ bd] sd").ply("<1 2 3>") ``` -------------------------------- ### Create Layered Chords and Bassline Source: https://strudel.cc/learn/tonal This example demonstrates creating a layered musical piece with chords and a bassline using `dict`, `layer`, `struct`, `voicing`, `set`, `mode`, `s`, and `cutoff`. ```javascript chord("*2") .dict('ireal').layer( x=>x.struct("[~ x]*2").voicing() , x=>n("0*4").set(x).mode("root:g2").voicing() .s('sawtooth').cutoff("800:4:2") ) ``` -------------------------------- ### Strudel Control Parameters Example Source: https://strudel.cc/technical-manual/repl Example demonstrating the use of Strudel's control parameter functions like 'note', 'cutoff', and 's' to shape event values. ```javascript note('c3 e3') .cutoff(1000) .s('sawtooth') .queryArc(0, 1) .map((hap) => hap.value); /* [ { note: 'c3', cutoff: 1000, s: 'sawtooth' } { note: 'e3', cutoff: 1000, s: 'sawtooth' } ] */ ``` -------------------------------- ### Offset and Modify with off (Table Example) Source: https://strudel.cc/workshop/pattern-effects This example demonstrates the `off` function for time-offsetting and modifying patterns, as shown in a table. ```haskell s("bd sd [~ bd] sd, hh*8").off(1/16, x=>x.speed(2)) ``` -------------------------------- ### Pitch Envelope Example Source: https://strudel.cc/learn/effects Demonstrates controlling pitch with envelopes, including scale, sound source, pitch envelope amount, vibrato, phaser, delay, room, size, and speed. ```javascript n("<-4,0 5 2 1>*<2!3 4>") .scale("/8:pentatonic") .s("gm_electric_guitar_jazz") .penv("<.5 0 7 -2>*2").vib("4:.1") .phaser(2).delay(.25).room(.3) .size(4).fast(1.5) ``` -------------------------------- ### Example JSON Payload from MQTT Source: https://strudel.cc/learn/input-output This shows an example of the JSON payload that Strudel sends for control patterns over MQTT, including sound and speed properties. ```json {"s":"sax","speed":2} {"s":"sax","speed":2} {"s":"sax","speed":3} {"s":"sax","speed":2} ... ``` -------------------------------- ### Generate All Default Chords with Voicing Source: https://strudel.cc/understand/voicings This example demonstrates generating a comprehensive list of all available chord symbols using the default dictionary, applying voicing with a room of 0.5. It showcases the variety of chord types supported. ```javascript chord(`< C2 C5 C6 C7 C9 C11 C13 C69 Cadd9 Co Ch Csus C^ C- C^7 C-7 C7sus Ch7 Co7 C^9 C^13 C^7#11 C^9#11 C^7#5 C-6 C-69 C-^7 C-^9 C-9 C-add9 C-11 C-7b5 Ch9 C-b6 C-#5 C7b9 C7#9 C7#11 C7b5 C7#5 C9#11 C9b5 C9#5 C7b13 C7#9#5 C7#9b5 C7#9#11 C7b9#11 C7b9b5 C7b9#5 C7b9#9 C7b9b13 C7alt C13#11 C13b9 C13#9 C7b9sus C7susadd3 C9sus C13sus C7b13sus C Caug CM Cm CM7 Cm7 CM9 CM13 CM7#11 CM9#11 CM7#5 Cm6 Cm69 Cm^7 C-M7 Cm^9 C-M9 Cm9 Cmadd9 Cm11 Cm7b5 Cmb6 Cm#5 >`).voicing().room(.5) ``` -------------------------------- ### Mini Notation Highlighting Example Source: https://strudel.cc/learn/visual-feedback Demonstrates mini notation highlighting with double quotes and backticks. Active parts of the notation are highlighted. ```javascript n("<0 2 1 3 2>*8") .scale("/4:minor:pentatonic") .s("supersaw").lpf(300).lpenv("<4 3 2>*4") ``` -------------------------------- ### Triangle Signal Example Source: https://strudel.cc/learn/signals Generates a triangle signal, segments it, and scales to C minor. ```javascript n(tri.segment(8).range(0,7)).scale("C:minor") ``` -------------------------------- ### Lowpass Filter Envelope Modulation Example Source: https://strudel.cc/learn/effects Demonstrates setting various lowpass filter envelope parameters including attack, decay, sustain, release, and modulation depth. This example shows how to dynamically control the cutoff frequency of a lowpass filter. ```javascript note("[c eb g ](3,8,<0 1>)".sub(12)) .s("/64") .lpf(sine.range(300,2000).slow(16)) .lpa(0.005) .lpd(perlin.range(.02,.2)) .lps(perlin.range(0,.5).slow(3)) .lpq(sine.range(2,10).slow(32)) .release(.5) .lpenv(perlin.range(1,8).slow(2)) .ftype('24db') .room(1) .juxBy(.5,rev) .sometimes(add(note(12))) .stack(s("bd*2").bank('RolandTR909')) .gain(.5).fast(2) ``` -------------------------------- ### Combined Tune Example Source: https://strudel.cc/workshop/first-effects A demonstration of combining multiple effects and patterns into a single sequence. ```javascript $: sound("hh*8").gain("[.25 1]*4") $: sound("bd*4,[~ sd:1]*2") $: note("<[c2 c3]*4 [bb1 bb2]*4 [f2 f3]*4 [eb2 eb3]*4>") .sound("sawtooth").lpf("200 1000 200 1000") $: note("<[c3,g3,e4] [bb2,f3,d4] [a2,f3,c4] [bb2,g3,eb4]>") .sound("sawtooth").vowel("") ``` -------------------------------- ### Specify Base Pitch and Load Samples from GitHub Source: https://strudel.cc/learn/samples Load samples from a GitHub repository and specify a base pitch for accurate tuning when using the 'note' function. This example uses 'gtr' and 'moog' samples. ```javascript samples({ 'gtr': 'gtr/0001_cleanC.wav', 'moog': { 'g3': 'moog/005_Mighty%20Moog%20G3.wav' }, }, 'github:tidalcycles/dirt-samples'); note("g3 [bb3 c4] @2").s("gtr,moog").clip(1) .gain(.5) ``` -------------------------------- ### Another Drum Pattern Example Source: https://strudel.cc/learn/mondo-notation Another drum pattern example using 'tr909' bank and speed modification. ```mondo $ s oh*4 # press # bank tr909 # speed.8 ``` -------------------------------- ### Sine Signal Example Source: https://strudel.cc/learn/signals Creates a sine signal, segments it, and scales it to a C minor scale. ```javascript n(sine.segment(16).range(0,15)) .scale("C:minor") ``` -------------------------------- ### Initialize Hydra and run visuals Source: https://strudel.cc/learn/hydra Call initHydra at the top of your script to enable Hydra functionality. This example demonstrates basic oscillator chaining and audio synthesis. ```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) ``` -------------------------------- ### Send MIDI notes with controller options Source: https://strudel.cc/learn/input-output Send MIDI notes and configure options for MIDI controllers. This example uses the 'IAC Driver' and sets `isController` to true and specifies a `midimap`. ```javascript $: note("d e c a f").midi('IAC Driver', { isController: true, midimap: 'default'}) ``` -------------------------------- ### Cosine Signal Example Source: https://strudel.cc/learn/signals Combines sine and cosine signals, segments them, and scales to C minor. ```javascript n(stack(sine,cosine).segment(16).range(0,15)) .scale("C:minor") ``` -------------------------------- ### Set Loop Begin Point with .loopBegin() Source: https://strudel.cc/learn/samples Use .loopBegin() to specify the start time for sample looping. The time parameter is a value between 0 and 1, representing the sample's length. ```tidalcycles s("space").loop(1) .loopBegin("<0 .125 .25>")._scope() ``` -------------------------------- ### Probabilistic Binary Random Signal Example Source: https://strudel.cc/learn/signals Applies a binary random signal with a specified probability to control panning, allowing for controlled randomness. ```javascript s("hh*10").pan(brandBy(0.2)) ``` -------------------------------- ### Tidal Syntax Example Source: https://strudel.cc/learn/strudel-vs-tidal Illustrates Tidal's use of the '$' operator and custom infix operators. ```haskell iter 4 $ every 3 (||+ n "10 20") $ (n "0 1 3") # s "triangle" # crush 4 ``` -------------------------------- ### Magical Strumming with Effects Source: https://strudel.cc/learn/xen This example showcases a strumming pattern with `legato()` and `room()` effects to create a magical, washed-out sound, particularly effective for tunings with subtle detuning. ```javascript i("[0 1 2 3 4 5 6]@0.3 - .add("<2 5 8 1>")) .tune("sanza") .mul(getFreq('c3')).freq() .legato("3").room(1).rfade(5) ``` -------------------------------- ### Coastline Composition Example Source: https://strudel.cc/workshop/getting-started A complex musical pattern demonstrating drum, chord, and melody sequencing using Strudel's pattern manipulation functions. ```javascript // "coastline" @by eddyflux // @version 1.0 samples('github:eddyflux/crate') setcps(.75) let chords = chord("/4").dict('ireal') stack( stack( // DRUMS s("bd").struct("<[x*<1 2> [~@3 x]] x>"), s("~ [rim, sd:<2 3>]").room("<0 .2>"), n("[0 <1 3>]*<2!3 4>").s("hh"), s("rd:<1!3 2>*2").mask("<0 0 1 1>/16").gain(.5) ).bank('crate') .mask("<[0 1] 1 1 1>/16".early(.5)) , // CHORDS chords.offset(-1).voicing().s("gm_epiano1:1") .phaser(4).room(.5) , // MELODY n("<0!3 1*2>").set(chords).mode("root:g2") .voicing().s("gm_acoustic_bass"), chords.n("[0 <4 3 <2 5>>*2](<3 5>,8)") .anchor("D5").voicing() .segment(4).clip(rand.range(.4,.8)) .room(.75).shape(.3).delay(.25) .fm(sine.range(3,8).slow(8)) .lpf(sine.range(500,1000).slow(8)).lpq(5) .rarely(ply("2")).chunk(4, fast(2)) .gain(perlin.range(.6, .9)) .mask("<0 1 1 0>/16") ) .late("[0 .01]*4").late("[0 .01]*2").size(4) ``` -------------------------------- ### Quantize Notes to a Scale with Octave and Mode Source: https://strudel.cc/learn/tonal This example uses `scale()` to quantize notes to a scale, specifying a scale with octave and mode variations like 'C:/2'. It also sets the instrument using `.s('piano')`. ```javascript n("[0,7] 4 [2,7] 4") .scale("C:/2") .s("piano") ``` -------------------------------- ### Integer Random Signal Example Source: https://strudel.cc/learn/signals Generates a sequence of random integers to select notes from a scale, creating varied melodic structures. ```javascript // randomly select scale notes from 0 - 7 (= C to C) n(irand(8)).struct("x x*2 x x*3").scale("C:minor") ``` -------------------------------- ### Sawtooth Signal Example Source: https://strudel.cc/learn/signals Generates a sawtooth signal and applies it to notes. The .clip() method limits the signal's influence. ```javascript note("">*8) .clip(saw.slow(2)) ``` ```javascript n(saw.range(0,8).segment(8)) .scale('C major') ``` -------------------------------- ### Transpiling Mini-notation String Source: https://strudel.cc/technical-manual/repl This example shows how a mini-notation string is transpiled into a Strudel pattern function call. The `m` function wraps the string and includes source location information. ```javascript note("c3 [e3 g3]*2") ``` ```javascript note(m('c3 [e3 g3]*2', 5)) ``` -------------------------------- ### Create a 5-Beat Rhythm Source: https://strudel.cc/understand/cycles Demonstrates creating a rhythm with 5 beats per cycle. This example uses a longer sequence of drum sounds. ```strudel s("bd hh hh bd hh hh bd rim bd hh") ``` -------------------------------- ### Basic Drum Pattern Example Source: https://strudel.cc/learn/mondo-notation A simple drum pattern using Mondo Notation with the 'tr909' bank and clip setting. ```mondo $ s [bd bd bd bd] # bank tr909 # clip .5 ``` -------------------------------- ### Send MIDI notes with port pattern Source: https://strudel.cc/learn/input-output Sends MIDI notes and specifies a pattern for the MIDI port. This example demonstrates sending notes 'c a f e' to ports specified by the pattern '<0 1 2 3>' and then calling `.midi()`. ```javascript note("c a f e").midiport("<0 1 2 3>").midi() ``` -------------------------------- ### Pluck with Large Reverb (Default Orbit) Source: https://strudel.cc/learn/effects Demonstrates a pluck sound with a large reverb using the default orbit (1). This example is intended for comparison with the next. ```javascript s("triangle*4").decay(0.5).n(irand(12)).scale('C minor') .room(1).roomsize(10) ``` -------------------------------- ### Euclidean Rhythm: Pop Clave Example Source: https://strudel.cc/learn/mini-notation Generates a 'Pop Clave' rhythm using Euclidean rhythm notation. The format is `(beats, segments, offset)`, where offset is optional. ```javascript s("bd(3,8,0)") ``` -------------------------------- ### Load samples from GitHub repository Source: https://strudel.cc/learn/samples Use the 'samples' shortcut to load audio samples directly from a GitHub repository. Assumes a strudel.json file exists at the repository's root. The default branch is 'main'. ```javascript samples('github:tidalcycles/dirt-samples') ``` ```javascript s("bd sd bd sd,hh*16") ``` -------------------------------- ### Mouse X Position Signal Example Source: https://strudel.cc/learn/signals Maps the mouse's X position to control note selection within a scale, allowing for interactive musical changes. ```javascript n(mousex.segment(4).range(0,7)).scale("C:minor") ``` -------------------------------- ### Integrate Strudel with Custom UI using @strudel/web Source: https://strudel.cc/technical-manual/project-start Use the @strudel/web package to integrate Strudel with your own custom user interface. This example shows basic play/stop functionality. ```html ``` -------------------------------- ### Combo tune with fmap for Changing Base Note Source: https://strudel.cc/learn/xen Combine `tune()` with `fmap()` to dynamically change the base note of the scale. This example uses `legato()`, `room()`, `rdim()`, and `rlp()` for effects. ```javascript i("9 11 12 10 - - -").tune("gunkali") .mul("".fmap(getFreq)) .freq().legato("2 .7").room("1:15").rdim(8500).rlp(14000).rfade(8) ``` -------------------------------- ### Strudel Event Scheduling Example Source: https://strudel.cc/technical-manual/repl A simplified JavaScript implementation of Strudel's event scheduler using setInterval to query a pattern for events within a time interval. ```javascript let pattern = seq('c3', ['e3', 'g3']); // pattern from user let interval = 0.5; // query interval in seconds let time = 0; // beginning of current time span let minLatency = 0.1; // min time before a hap should trigger setInterval(() => { const haps = pattern.queryArc(time, time + interval); time += interval; // increment time haps.forEach((hap) => { const deadline = hap.whole.begin - time + minLatency; onTrigger(hap, deadline, duration); }); }, interval * 1000); // query each "interval" seconds ``` -------------------------------- ### Send Plain Text to MQTT Source: https://strudel.cc/learn/input-output This snippet demonstrates sending a simple string 'hello world' to an MQTT broker. It configures the topic, server address, and client ID. ```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) ) ``` -------------------------------- ### Declare Different Samples for Keyboard Regions Source: https://strudel.cc/learn/samples Configure samples for specific keyboard regions (e.g., 'g2', 'g3', 'g4') to ensure the sampler picks the closest matching sample for a given note. This example uses 'moog' samples from a GitHub repository. ```javascript setcpm(60) samples({ 'moog': { 'g2': 'moog/004_Mighty%20Moog%20G2.wav', 'g3': 'moog/005_Mighty%20Moog%20G3.wav', 'g4': 'moog/006_Mighty%20Moog%20G4.wav', }}, 'github:tidalcycles/dirt-samples') note("g2!2 !2, g4 f4]>@2") .s('moog').clip(1) .gain(.5) ``` -------------------------------- ### Chaining Functions in Mondo Notation Source: https://strudel.cc/learn/mondo-notation Demonstrates chaining function calls using the '#' operator, similar to method chaining in JavaScript. This example applies multiple transformations to a base pattern. ```mondo n <0 2 4 [3 1] -1>*4 # scale C4:minor # jux rev # dec .2 # delay .5 ``` ```javascript n("<0 2 4 [3 1] -1>*4") .scale("C4:minor") .jux(rev) .dec(.2) .delay(.5) ``` -------------------------------- ### Euclidean Rhythm Parameters: Offset Source: https://strudel.cc/learn/mini-notation Demonstrates the 'offset' parameter in Euclidean rhythms, which controls the starting position of the beat distribution. A secondary rhythm is used to clearly hear the positional differences. ```javascript s("bd(3,8,0), hh cp") ``` ```javascript s("bd(3,8,3), hh cp") ``` ```javascript s("bd(3,8,5), hh cp") ``` -------------------------------- ### Configure Default MIDI Mappings with defaultmidimap Source: https://strudel.cc/learn/input-output Set up a default MIDI mapping using `defaultmidimap` when no specific `midimap` port is specified. ```javascript defaultmidimap({ lpf: 74 }) $: note("c a f e").midi(); $: lpf(sine.slow(4).segment(16)).midi(); ``` -------------------------------- ### Run Through Sample Bank with Early Offset Source: https://strudel.cc/recipes/recipes Adjust the starting point of the `run` sequence using `early` to find the beginning of a phrase within the samples. The offset is a fraction of the total samples. ```javascript samples('bubo:fox') n(run(8)).s("ftabla").early(2/8) ``` -------------------------------- ### Apply Lowpass Filter Sweep with Mask and When Source: https://strudel.cc/learn/faq Use `all(x=>x.when(...))` combined with `.mask()` to apply effects like a lowpass filter sweep to all patterns. This example filters everything every 8 cycles. ```strudel all(x=>x.when("<0!7 1>", x=>x.lpf(saw.range(200, 2000)))) ``` -------------------------------- ### Chord Voicings with IReal Pro Dictionary Source: https://strudel.cc/blog Demonstrates generating complex chord voicings using the `chord` function and the 'ireal' dictionary, combined with `.voicing()` for sophisticated harmonic structures. Includes effects like phaser and reverb. ```javascript chord("/2") .dict('ireal').voicing() .s("sawtooth") .lpf(400).lpa(.5).lpenv(4) .phaser(4).room(.5) ``` -------------------------------- ### xen with Multiple Scale Options Source: https://strudel.cc/learn/xen Shows how `xen()` can accept a string of multiple scale names or EDOs, allowing for complex or layered tuning systems. ```javascript i("0 1 2 3 4 5 6 7").xen("<5edo 10edo 15edo hexany15>") ``` -------------------------------- ### enableMotion() Source: https://strudel.cc/learn/devicemotion Initializes the device motion sensors and requests user permission for access. ```APIDOC ## enableMotion() ### Description Prompts the user for permission to access device motion sensors and enables motion sensing capabilities. ### Method Function Call ### Request Example enableMotion(); ``` -------------------------------- ### firstOf Source: https://strudel.cc/learn/conditional-modifiers Applies a function every n cycles, starting from the first cycle. ```APIDOC ## firstOf ### Description Applies the given function every n cycles, starting from the first cycle. ### Parameters - **n** (number) - Required - How many cycles - **func** (function) - Required - Function to apply ### Request Example note("c3 d3 e3 g3").firstOf(4, x=>x.rev()) ``` -------------------------------- ### lastOf Source: https://strudel.cc/learn/conditional-modifiers Applies a function every n cycles, starting from the last cycle. ```APIDOC ## lastOf ### Description Applies the given function every n cycles, starting from the last cycle. ### Parameters - **n** (number) - Required - How many cycles - **func** (function) - Required - Function to apply ### Request Example note("c3 d3 e3 g3").lastOf(4, x=>x.rev()) ``` -------------------------------- ### Demonstrating Sound Index Wrapping Source: https://strudel.cc/learn/samples Illustrates how requesting sound indices beyond the available count results in playing the same sounds due to wrap-around behavior. ```javascript s("hh*8").bank("RolandTR909").n("0 1 2 3 4 5 6 7") ``` -------------------------------- ### Random Signal Example Source: https://strudel.cc/learn/signals Applies a random signal to control the cutoff frequency of a sound pattern. ```javascript // randomly change the cutoff s("bd*4,hh*8").cutoff(rand.range(500,8000)) ``` -------------------------------- ### Initialize Gamepad Source: https://strudel.cc/learn/input-devices Initialize a gamepad instance using an optional index parameter, which defaults to 0. ```javascript // Initialize gamepad (optional index parameter, defaults to 0) const gp = gamepad(0) note("c a f e").mask(gp.a) ``` -------------------------------- ### Enable Device Motion Sensing Source: https://strudel.cc/learn/devicemotion Initializes the motion sensors and requests user permission. ```javascript enableMotion() ``` -------------------------------- ### Additive Synthesis - Phases Source: https://strudel.cc/learn/synths Control the starting phase of each harmonic in periodic waveforms to add depth to sounds. ```APIDOC ## Additive Synthesis - Phases ### Description Control the starting phase of each harmonic in periodic waveforms to add depth to sounds. ### Method N/A (This describes a parameter usage) ### Endpoint N/A ### Parameters #### Query Parameters - **phases** (number|Pattern) - Optional - Defines the phase of each harmonic. ### Request Example ``` 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)) ``` ### Response N/A ``` -------------------------------- ### Loop Sample with .loop() Source: https://strudel.cc/learn/samples Use the .loop() effect to loop a sample. Set the 'on' parameter to 1 to enable looping. ```tidalcycles s("casio").loop(1) ``` -------------------------------- ### Nudge pattern earlier Source: https://strudel.cc/learn/time-modifiers Nudges a pattern to start earlier in time. Equivalent to Tidal's '<~' operator. ```haskell "bd ~ ".stack("hh ~ ".early(.1)).s() ``` -------------------------------- ### Strudel Equivalent Syntax Source: https://strudel.cc/learn/strudel-vs-tidal Shows the direct translation of the Tidal example into Strudel, highlighting the absence of '$' and custom operators. ```javascript iter(4, every(3, add.squeeze("10 20"), n("0 1 3").s("triangle").crush(4))) ``` -------------------------------- ### Nudge pattern later Source: https://strudel.cc/learn/time-modifiers Nudges a pattern to start later in time. Equivalent to Tidal's '~>' operator. ```haskell "bd ~ ".stack("hh ~ ".late(.1)).s() ``` -------------------------------- ### Perlin Noise Signal Example Source: https://strudel.cc/learn/signals Uses Perlin noise to control the cutoff frequency of a sound pattern, introducing variation. ```javascript // randomly change the cutoff s("bd*4,hh*8").cutoff(perlin.range(500,8000)) ``` -------------------------------- ### Load Samples from Disk in Strudel Desktop App Source: https://strudel.cc/blog Use this function in the Strudel Desktop App to load samples from a specified directory. The app creates a strudel.json file to map available samples upon first run. ```javascript samples('~/music/xxx'); s('my_sound'); ``` -------------------------------- ### Recap: Mini-Notation Syntax Source: https://strudel.cc/workshop/first-sounds Summary of basic syntax elements. ```javascript sound("bd bd sd hh") ``` ```javascript sound("hh:0 hh:1 hh:2 hh:3") ``` ```javascript sound("metal - jazz jazz:1") ``` ```javascript sound("") ``` ```javascript sound("bd wind [metal jazz] hh") ``` ```javascript sound("bd [metal [jazz [sd cp]]]") ``` ```javascript sound("bd sd*2 cp*3") ``` ```javascript sound("bd*2, hh*2 [hh oh]") ``` -------------------------------- ### Silence a pattern Source: https://strudel.cc/learn/conditional-modifiers Use `hush` to silence a pattern. This example stacks two patterns, one of which is silenced using `hush()`. ```Haskell stack( s("bd").hush(), s("hh*3") ) ``` -------------------------------- ### Set Reverb Lowpass Frequency Source: https://strudel.cc/learn/effects Sets the lowpass starting frequency in hertz for the reverb. Recalculates 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) ``` -------------------------------- ### Using n for Scale and Sample Indexing Source: https://strudel.cc/learn/faq Demonstrates using the n method to reference scale degrees and sample indices within a pattern. ```javascript n("<[0 1 2 3@3 -@2] [3 2 1 0@3 -@2] >") .scale("A:minor:pentatonic") .s("gm_acoustic_guitar_steel").n("<0 1 2 3>/2") ``` -------------------------------- ### Implement Wavetable Synthesis Source: https://strudel.cc/learn/synths Usage of the 'wt_' prefix to load samples as wavetables for synthesis. ```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() ``` -------------------------------- ### Playing Patterns in Parallel with $: in Strudel CC Source: https://strudel.cc/workshop/recap The `$: ` prefix plays subsequent patterns in parallel. Each `$: ` starts a new parallel track. ```strudel $: s("bd sd") ``` ```strudel $: note("c eb g") ``` -------------------------------- ### Play imported local samples Source: https://strudel.cc/learn/samples After importing a folder of audio samples via the 'sounds' tab in the REPL, individual samples can be played using their imported names and zero-based indexing. ```javascript s("swoop:0 swoop:1 smash:2") ``` -------------------------------- ### Create Custom Strudel Parameters Source: https://strudel.cc/technical-manual/repl Example of creating and using custom control parameters 'x' and 'y' in Strudel to generate a circular pattern. ```javascript const { x, y } = createParams('x', 'y'); x(sine.range(0, 200)).y(cosine.range(0, 200)); ``` -------------------------------- ### Binary Random Signal Example Source: https://strudel.cc/learn/signals Uses a binary random signal to control the panning of a hi-hat pattern, creating stereo variation. ```javascript s("hh*10").pan(brand) ```