### Strudel Music Composition Example Source: https://strudel.cc/workshop/getting-started/index This code snippet demonstrates a complex music composition using Strudel's pattern language. It utilizes sample playback, effects like phaser and delay, and procedural sound generation with Perlin noise. Dependencies include predefined samples and Strudel's core functions. ```strudel // "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) ``` -------------------------------- ### Complete Strudel Composition Example: Coastline Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt This is a complete Strudel composition titled 'Coastline' by eddyflux, demonstrating the integration of various features learned previously. It includes drum patterns, chord progressions with effects, a melody, and complex sequenced parts, showcasing advanced Strudel capabilities in a full track context. ```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) ``` -------------------------------- ### Basic Sound Sequencing with s() in JavaScript Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt The s() function in Strudel is used to create sound patterns with samples or synthesizers. It is fundamental for composing music in Strudel. Examples demonstrate playing basic drum patterns, layering sounds, using sample variations, and creating polyrhythmic patterns. ```javascript s("bd bd bd bd") s("bd ~ sd ~, hh hh hh hh") s("sd:1 sd:2 sd:3 sd:4") s("[bd sd] hh [bd bd] hh") ``` -------------------------------- ### Sample Loading with samples() in JavaScript Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt The samples() function allows loading custom sample banks, typically from sources like GitHub. Once loaded, these samples can be used with the s() function by specifying the bank name. Examples show loading a remote sample pack and using its samples, as well as combining custom samples with built-in ones. ```javascript samples('github:eddyflux/crate') s("kick snare hat clap") .bank('crate') .gain(0.8) stack( s("bd sd").bank('crate'), s("hh hh hh hh") ) ``` -------------------------------- ### Apply Pattern Transformations in Strudel (rarely, chunk, fast) Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt This code demonstrates structural transformations for pattern development in Strudel. It includes examples of doubling pattern speed occasionally using `rarely()`, processing sections differently with `chunk()`, and applying variations with `fast()`. These techniques allow for creating more dynamic and evolving musical phrases. ```javascript // Double pattern speed occasionally s("bd sd bd sd") .rarely(ply("2")) // Chunk and process sections differently n("0 2 4 7") .scale("C:major") .s("piano") .chunk(4, fast(2)) // Fast pattern variation s("hh*4").chunk(2, fast(1.5)).gain(0.6) ``` -------------------------------- ### Add Movement with Strudel Modulation Effects (Phaser, FM) Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt This snippet demonstrates adding movement and character to sounds using Strudel's phaser and frequency modulation (FM) effects. It also includes an example of the 'shape' effect, often used for distortion. These are useful for creating dynamic and evolving textures. ```javascript // Phaser effect s("piano").n("0 4 7").phaser(4) // Frequency modulation s("sine") .n("0 7 12") .fm(sine.range(3, 8).slow(8)) .gain(0.4) // Shape (distortion) s("sawtooth").n("0 3 7").shape(0.5).gain(0.3) ``` -------------------------------- ### Tempo Control with setcps() in JavaScript Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt The setcps() function controls the tempo (cycles per second) for the entire Strudel composition. This function is crucial for setting the overall speed and feel of the music. Examples demonstrate setting different tempos for various musical styles, from ambient to fast-paced electronic music. ```javascript setcps(2) setcps(0.5) s("pad pad pad pad").s("sawtooth").room(0.9).gain(0.3) setcps(2.75) s("bd*4, [~ sd]*2, hh*8").speed(1.2) ``` -------------------------------- ### Chord Construction with chord() in JavaScript Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt The chord() function generates chord structures using standard music theory notation. It supports various chord types and can be combined with .voicing(), .segment(), and .dict() for detailed control over chord voicings and arpeggiation. Examples include basic progressions, jazz-style chords, and arpeggiated patterns. ```javascript chord("Cmaj7 Fmaj7 G7 Cmaj7") .voicing() .s("sawtooth") .room(0.5) let chords = chord("/4").dict('ireal') chords.voicing().s("gm_epiano1:1").phaser(4) chord("Am7 Dm7 G7 Cmaj7") .segment(16) .s("piano") .delay(0.25) ``` -------------------------------- ### Manage Volume and Clipping with Strudel Dynamic Control Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt This code section illustrates dynamic control in Strudel, focusing on managing volume, clipping, and amplitude modulation. Examples include dynamic gain with Perlin noise, using clip for gating, and volume automation with array notation. These are essential for shaping the loudness and expressive qualities of sounds. ```javascript // Dynamic gain with Perlin noise s("hh*16").gain(perlin.range(0.3, 0.9)) // Clip for gating effect s("pad").clip(rand.range(0.4, 0.8)) // Volume automation s("bd sd").gain("<0.8 0.6 0.9 0.5>") ``` -------------------------------- ### Layering Patterns with stack() in JavaScript Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt The stack() function is used to layer multiple patterns, allowing them to play simultaneously. This is essential for building complex musical arrangements by combining different rhythmic and melodic elements. Examples include a simple drum stack and a more complex arrangement with bass and melody lines. ```javascript stack( s("bd bd bd bd"), s("~ sd ~ sd"), s("hh hh hh hh").gain(0.6) ) stack( s("bd").struct("<[x*<1 2> [~@3 x]] x>"), s("~ [rim, sd:<2 3>]").room("<0 .2>"), n("<0!3 1*2>").scale("G2:minor").s("sawtooth"), n("0 4 7 12").scale("G4:minor").s("piano").delay(0.5) ) ``` -------------------------------- ### Shape Frequencies with Strudel Filter Effects (LPF, HPF) Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt This section shows how to shape sound frequencies using lowpass (LPF), highpass (HPF), and resonant filters in Strudel. Examples include LPF with cutoff automation, HPF with resonance, and a resonant filter sweep. These effects are useful for sound design and emphasis. ```javascript // Lowpass filter with cutoff automation s("sawtooth") .n("0 2 4 7") .lpf(sine.range(200, 2000).slow(4)) .lpq(5) // Highpass filter s("pad").hpf(500).hpq(2).gain(0.4) // Resonant filter sweep s("bd sd bd sd").lpf("<200 400 800 1600>").resonance(10) ``` -------------------------------- ### Structure Modification with struct() in JavaScript Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt The struct() function applies a rhythmic structure to a pattern, using a binary sequence to trigger sounds. This is particularly useful for creating Euclidean rhythms or complex syncopated patterns. Examples show applying structures to drum sounds, complex rhythms, and chord progressions. ```javascript s("bd").struct("x(5,8)") s("bd").struct("<[x*<1 2> [~@3 x]] x>") chord("Cm7 F7").struct("x ~ x ~").s("piano") ``` -------------------------------- ### Optimize Voice Leading with Strudel's voicing() Function Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt This code demonstrates the `voicing()` function in Strudel, which optimizes chord inversions for smooth voice leading. Examples include creating a smooth jazz chord progression and anchoring a chord progression to a specific note to control voice leading. This function is key for creating musically pleasing harmonic progressions. ```javascript // Smooth jazz chord progression chord("Cmaj9 Am11 Dm9 G13") .voicing() .s("gm_epiano1:1") .room(0.5) // Anchor to specific note for voice leading chord("Cmaj7 Fmaj7 G7 Cmaj7") .anchor("E5") .voicing() .s("pad") .gain(0.4) ``` -------------------------------- ### Note and Scale Selection with n() in JavaScript Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt The n() function is used to specify note numbers or scale degrees for melodic and harmonic content. It can be combined with .scale() and .s() to define the musical context and instrument. Examples show creating melodies, chord progressions, and rhythmic variations using scale degrees. ```javascript n("0 2 4 7").scale("C:major").s("piano") n("0,4,7 2,5,9 5,9,12 7,11,14") .scale("C:minor") .s("sawtooth") .gain(0.3) n("0 [2 4] <7 5> 4") .scale("D:dorian") .s("triangle") .cutoff(1000) ``` -------------------------------- ### Pattern Masking with mask() in JavaScript Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt The mask() function applies rhythmic gates to patterns, controlling when they play within a cycle. It allows for intricate rhythmic programming by selectively enabling or disabling pattern events. Examples cover simple on/off masking, complex polyrhythmic masking, and layer-specific masking within a stack. ```javascript s("bd sd bd sd").mask("1 0 1 0") s("hh*16") .mask("<[0 1] 1 1 1>/16") .gain(0.5) stack( s("bd*4"), s("pad").mask("<0 1 1 0>/16").room(0.8) ) ``` -------------------------------- ### Rotate Patterns with Strudel's offset() Function Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt This snippet explains and demonstrates the `offset()` function in Strudel, which rotates a pattern by a specified number of steps. It shows practical applications such as rotating a chord progression to create harmonic variations and generating counter-melodies by offsetting a note pattern. ```javascript // Rotate chord progression let chords = chord("Cmaj7 Am7 Dm7 G7") stack( chords.voicing().s("piano"), chords.offset(-1).voicing().s("sawtooth").gain(0.2) ) // Create counter-melody n("0 2 4 7") .scale("C:major") .s("triangle") .stack( n("0 2 4 7").offset(2).s("sine").gain(0.3) ) ``` -------------------------------- ### Control Reverb, Delay, and Panning with Strudel Spatial Effects Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt This snippet demonstrates how to add spatial depth to sounds using Strudel's reverb, delay, and panning effects. It includes examples for room reverb, delay with feedback, stereo panning using a sine wave, and controlling reverb size. No specific external dependencies are required beyond the Strudel library. ```javascript // Add room reverb s("sd sd sd sd").room(0.5) // Delay with feedback s("piano").n("0 4 7").delay(0.25).delaytime(0.375).delayfeedback(0.6) // Stereo panning s("hh*8").pan(sine.slow(4)) // Size control for reverb s("pad").room(0.8).size(4).s("sawtooth") ``` -------------------------------- ### Time Shifting with early() and late() in JavaScript Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt The early() and late() functions modify pattern playback timing by shifting events forward or backward within a cycle. These are used to create subtle timing variations, swing effects, or pre-trigger sounds. Examples demonstrate creating swing, layered timing variations, and pre-triggering sounds. ```javascript stack( s("bd sd bd sd"), s("hh*8").late(0.01) ) s("pad") .late("[0 .01]*4") .late("[0 .01]*2") .room(0.9) s("sd").early(0.5).room(0.3) ``` -------------------------------- ### Segment Patterns with Strudel's segment() Function Source: https://context7.com/context7/strudel_cc-workshop-getting-started/llms.txt This snippet illustrates the `segment()` function in Strudel, used to divide patterns into equal time segments for precise timing control. Examples show quantizing notes to 16th notes and using `segment()` combined with `clip()` for rhythmic gating effects on chords. This is useful for rhythmic precision and complex sequencing. ```javascript // Quantize to 16th notes n("0 4 7 12") .segment(16) .s("piano") // Combined with clip for rhythmic gating chord("Am7 Dm7") .segment(4) .clip(rand.range(0.4, 0.8)) .s("sawtooth") .room(0.75) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.