### Named Arguments Example Source: https://loopmaster.xyz/tutorials/zero-to-hero Pass arguments to a function by specifying the parameter name followed by the value. This allows arguments to be in any order and improves readability. ```js sd() |> velvet($, decay: 0.6) |> out($) ``` -------------------------------- ### TB-303 with Drums and Automation Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Combines the full TB-303 sound with drums and further filter automation, including fractal noise. This example demonstrates a complete track setup. ```js drums() |> out($) envelope=ad(attack:.001,decay:1,exponent:12.5,trig:every(1/8)) pos=t*2 note=[g1,g2,g0,b2][pos] accent=[.7k,21.8k,.8k,.4k, .7k,12.8k,2.8k,.4k][pos]*.5 // <-- tweak this! slide=[1.8,.03,.8,.01, 1.8,.8,1.8,.03][pos] ramp(note |> slew($,slide,.1,exp:2)) // <-- try changing to sqr! |> diodeladder($, cutoff:200+(accent |> slew($,.08,.06,3))*envelope +fractal(123,.006)**4*5k, // <-- and this! q:.98, k:0.0025, sat:.9 ) |> tanh($*25) |> out($*.15) ``` -------------------------------- ### Chain Operations with Pipe Operator Source: https://loopmaster.xyz/tutorials/zero-to-hero Demonstrates chaining multiple operations using the pipe operator (`|>`). This example applies a low-pass filter before outputting the sound. ```javascript saw(440) |> lp($) |> out($) ``` -------------------------------- ### Positional Arguments Example Source: https://loopmaster.xyz/tutorials/zero-to-hero Pass arguments to a function based on their order. Ensure the arguments match the parameter order defined in the function signature. ```js sd() |> velvet($, 0.8, 0.4, 0.6) |> out($) ``` -------------------------------- ### Generate a Sine Wave Sound Source: https://loopmaster.xyz/tutorials/zero-to-hero Creates a 440Hz sine wave and outputs it to the speakers. This is the most basic sound generation example. ```javascript sine(hz:440) |> out($) ``` -------------------------------- ### Loop Master XYZ Music Generation Example Source: https://loopmaster.xyz/tutorials/zero-to-hero This snippet demonstrates a complete music generation sequence using Loop Master XYZ. It defines a scale, a chord progression, and then uses these to generate FM synth sounds, Rhodes piano chords, a bassline, and drums. It also includes audio mixing with compression and limiting. ```loopmaster scale = 'mixolydian' progr = [#i,#i,#vi,#v] chord = progr[t/2] fm = (in,trig) -> in |> sine($+sine($/2)*$)*ad(trig) |> lp($,cutoff:300+10000*ad(e:40,trig),q:1) fm(chord[t*2]*o4, euclid(3, 8, bar:1/2)) |> out($*.5) ;(chord*o4).map(hz->rhodes(hz,trig:euclid(3, 8, bar:1/2))).avg()*.8 |> out($*.5) saw(chord[0]*o2) |> lp($,chord[0]*o2,1.5)*.2 |> out($) drums() |> out($) mix => compressor($,threshold:-10) |> limiter($) ``` -------------------------------- ### Basic Sine Wave Kick Drum Foundation Source: https://loopmaster.xyz/tutorials/making-a-house-loop Establishes a basic sine wave as the foundation for a kick drum sound. This is a starting point and will sound like a constant tone. ```loop sine(hz:e1) |> out($) ``` -------------------------------- ### Define Comments Source: https://loopmaster.xyz/tutorials/zero-to-hero Illustrates the two types of comments: single-line comments starting with `//` and block comments enclosed in `/* */`. ```javascript // this is a single-line comment /* this is a block comment */ ``` -------------------------------- ### Define Various Data Types Source: https://loopmaster.xyz/tutorials/zero-to-hero Shows examples of different data types available in Loopmaster, including undefined, numbers, strings, booleans, arrays, audio, and functions. ```javascript none = undefined // the absence of a value number = 1.00 string = 'Hello, world!' // or "string" with double quotes boolean = true // or false array = [1, 2, 3, 4, 5] audio = sine(440) function = (x, y) -> x + y ``` -------------------------------- ### Define Arrays with Mixed Types Source: https://loopmaster.xyz/tutorials/zero-to-hero Provides examples of creating arrays containing various data types, including numbers, strings, booleans, other arrays, and functions. ```javascript numbers = [1, 2, 3, 4, 5] strings = ['Hello', 'world'] booleans = [true, false] functions = [x -> x * 2, x -> x * 3] arrays = [[1, 2, 3], [4, 5, 6]] mixed = [1, 'Hello', true, [1, 2, 3], x -> x * 2] ``` -------------------------------- ### Add Delay Effect to Signal Source: https://loopmaster.xyz/tutorials/zero-to-hero Apply a delay effect to a signal, creating echoes. This example adds a delayed version of the signal to itself, resulting in two distinct sounds. ```js saw(e4)*ad(trig:every(1/2)) |> $+delay($, seconds:0.25) |> out($) ``` -------------------------------- ### Recursive Function Example Source: https://loopmaster.xyz/tutorials/zero-to-hero Define a function that calls itself to solve a problem by breaking it down into smaller, self-similar subproblems. Ensure a base case to prevent infinite recursion. ```js factorial = n -> { if (n == 0) return 1 else return n * factorial(n-1) } print(factorial(5)) ``` -------------------------------- ### Closure Example Source: https://loopmaster.xyz/tutorials/zero-to-hero Functions can capture variables from their outer scope, forming a closure. This allows functions to retain state and access variables even after the outer function has finished executing. ```js makeVoice = (osc, lfoSpeed, lfoAmount) -> { hz -> osc(hz+lfosine(lfoSpeed)*lfoAmount) |> lp($)/2 } v0 = makeVoice(sine, 1/8, 444) v1 = makeVoice(tri, 1/2, 111) v0(c3) |> out($) v1(g3) |> out($) ``` -------------------------------- ### Envelope: Shaping Sine Wave Volume Source: https://loopmaster.xyz/tutorials/sound-synthesis-101 Applies an attack-decay envelope to the volume of a sine wave, creating a sound that starts sharply and fades out. Adjust attack and decay times for different fades. ```javascript sine(a3) * ad(attack:0.001, decay:0.5, trig:every(1/2)) |> out($) ``` -------------------------------- ### Create a Small Track with Various Synthesis Techniques Source: https://loopmaster.xyz/tutorials/sound-synthesis-101 Combines different synthesis methods like FM, noise-based hi-hats, basslines, and lead sounds with envelopes and filters to construct a musical piece. Requires understanding of scales, chords, envelopes, and basic signal processing. ```javascript scale = 'saba' chord = [#i, #ii, #iv, #v][t/4] env = ad(attack:0.001, decay:0.5, exponent:10, trig:every(1/4)) sine(c1 + 200*env) * env |> out($) trig = every(1/16) gauss(trig) * ad(.006,.04,exponent:5,trig)*[.3,.1,.9,.2][t*4] |> hp($,8k,1) |> out($) trig = euclid(5,8,2,bar:1/2) env = ad(attack:0.0001, decay:0.5, exponent:5, trig) hz=chord.markov(trig) sqr(hz*o1) * env |> lp($, cutoff:400 + 500*env) |> out($*.25) trig = euclid(3,8,0,bar:1/2) env = ad(attack:0.0001, decay:0.25, exponent:5, trig) sine(hz*o5+sine(hz*o4)*hz*o3) * env |> lp($, cutoff:500 + 4000 * env)|> out($*.35) chord.map(hz->tri(hz*o4+4*lfosine(1))) |> bp($,1800) |> out($*.3) ``` -------------------------------- ### Advance Melody with Array walk Method Source: https://loopmaster.xyz/tutorials/zero-to-hero A concise way to step through a melody array using the 'walk' method. It simplifies the triggering mechanism compared to 'step'. ```javascript melody=[c4, e4, a4, g4] saw(melody.walk(1/4)) * ad(trig:euclid(5, 8, bar:1/2)) |> out($) ``` -------------------------------- ### Create Chords from Scale Degrees Source: https://loopmaster.xyz/tutorials/zero-to-hero Constructs chords by selecting specific scale degrees and playing them together using 'map' and 'avg'. ```javascript scale = 'minor' chord = [#1, #3, #5, #7]*o4 chord.map(saw).avg() * ad(trig:euclid(5, 8, bar:1/2)) |> out($) ``` -------------------------------- ### Multi-Note Chord with Saw Waves Source: https://loopmaster.xyz/tutorials/making-a-house-loop Creates a chord sound by generating saw waves for multiple notes (E3, A3, C4), averaging them, and applying an attack-decay envelope. The output is attenuated to 0.2. ```loop trig=tram('-x',1/4) ;[e3,a3,c4].map(hz->saw(hz)).avg()*ad(attack:.05,decay:.4,trig) |> out($*.2) ``` -------------------------------- ### Lowpass Filter with Cutoff and Resonance Source: https://loopmaster.xyz/tutorials/zero-to-hero Configure a lowpass filter with specific cutoff frequency and resonance (q) parameters. The cutoff determines the attenuation point, while q controls resonance at that point. ```js saw(e4) |> lp($, cutoff:200, q:1) |> out($) ``` -------------------------------- ### Advance Melody with Array step Method Source: https://loopmaster.xyz/tutorials/zero-to-hero Uses the 'step' array method to advance through a melody sequence triggered by an impulse. Requires an impulse source like 'every(1/4)'. ```javascript melody=[c4, e4, a4, g4] saw(melody.step(every(1/4))) * ad(trig:euclid(5, 8, bar:1/2)) |> out($) ``` -------------------------------- ### Play Complex Patterns with Mini Notation Source: https://loopmaster.xyz/tutorials/zero-to-hero Utilizes mini notation for defining complex musical patterns, including note sequences and effects. Requires the 'play' function and a suitable callback. ```javascript play(mini('c4 f4 a4/2 e4'),({hz,trig})->saw(hz)*ad(trig)|>lp($,100+10k*ad(e:8,trig),1)) |> out($) ``` -------------------------------- ### Basic Saw Wave for Chords Source: https://loopmaster.xyz/tutorials/making-a-house-loop Generates a basic saw wave with an attack-decay envelope, serving as a building block for chord sounds. The output is attenuated to 0.2. ```loop trig=tram('-x',1/4) saw(hz:e3)*ad(attack:.05,decay:.4,trig) |> out($*.2) ``` -------------------------------- ### Gliding Bass Notes Source: https://loopmaster.xyz/tutorials/making-a-house-loop Implements gliding between bass notes using the `.glide(1/2)` method, creating smoother transitions between notes in the bassline. ```loop ;[e1,a1].glide(1/2) |> tri($) |> out($*.5) ``` -------------------------------- ### Add Swing to Melody with walk Method Source: https://loopmaster.xyz/tutorials/zero-to-hero Introduces rhythmic variation to a melody played with the 'walk' method by applying a 'swing' parameter. Adjust swing value for desired effect. ```javascript melody = [c4, e4, a4, g4] saw(melody.walk(1/4, swing:0.5)) * ad(trig:euclid(5, 8, bar:1/2)) |> out($) ``` -------------------------------- ### Execute Once Then Conditionally Iterate with do...while Loop Source: https://loopmaster.xyz/tutorials/zero-to-hero Execute a block of code at least once, then repeat as long as a specified condition is true. Useful when an action must always occur initially. ```js i = 0 do { saw(#scale[i*2]*o4)/3 |> out($) i += 1 } while (i < 3) ``` -------------------------------- ### Basic Triangle Wave Bass Foundation Source: https://loopmaster.xyz/tutorials/making-a-house-loop Creates a basic triangle wave for the bass sound. Triangle waves provide a warm, rounded tone suitable for house music basslines. ```loop ;[e1,a1][t] |> tri($) |> out($*.5) ``` -------------------------------- ### Attack-Decay Envelope with Custom Parameters Source: https://loopmaster.xyz/tutorials/zero-to-hero Customize the Attack-Decay envelope with specific attack and decay times. Adjusting these parameters shapes the sound's volume contour. ```js sine(a4) * ad(attack:0.1, decay:0.9, trig:every(1/2)) |> out($) ``` -------------------------------- ### Chain Multiple Audio Effects Source: https://loopmaster.xyz/tutorials/zero-to-hero Shows how to chain several audio processing steps, including a low-pass filter and tube saturation, using the pipe operator. ```javascript saw(440) |> lp($) |> tube($) |> out($) ``` -------------------------------- ### Conditional Output with if/else Source: https://loopmaster.xyz/tutorials/zero-to-hero Use `if` and `else` statements to execute different code blocks based on a boolean condition. This allows for dynamic behavior based on input or state. ```js (if (t % 4 < 2) saw(c4) else tri(e4)) |> out($) ``` -------------------------------- ### Create Melodies from Array using Time Index Source: https://loopmaster.xyz/tutorials/zero-to-hero Plays notes from a predefined melody array using the 't' (time) index. The index wraps around based on the array length. ```javascript melody=[c4, e4, a4, g4] saw(melody[t]) * ad(trig:euclid(5, 8, bar:1/2)) |> out($) ``` -------------------------------- ### Define Function with Multiple Parameters Source: https://loopmaster.xyz/tutorials/zero-to-hero Define functions that accept multiple parameters by enclosing them in parentheses and separating them with commas. This allows for more complex operations. ```js add = (x, y) -> x + y print(add(3, 7)) print(add(30, 12)) ``` -------------------------------- ### Output Sound Directly Source: https://loopmaster.xyz/tutorials/zero-to-hero An alternative syntax for outputting a sine wave directly to the speakers. It is functionally identical to the piped version but less readable. ```javascript out(sine(hz:440)) ``` -------------------------------- ### Send Signal to Output with 'out' Source: https://loopmaster.xyz/tutorials/zero-to-hero Directs an audio signal to the main output. Multiple 'out' calls can be used to combine different signals. ```javascript saw(e4)*ad(trig:every(1/2)) |> out($) ``` -------------------------------- ### Apply Post-Processing Effects with 'mix' Source: https://loopmaster.xyz/tutorials/zero-to-hero Applies a chain of effects to the overall signal after all individual tracks have been processed. Use '=>' to define the effect chain. ```javascript drums() |> out($) mix => hp($,cutoff:1000) ``` -------------------------------- ### TB-303 with Accents and Slides Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Implements TB-303 accents and slides using the `slew` function to shape note transitions and dynamics. Experiment with accent and slide values to alter the character. ```js envelope=ad(attack:.001,decay:1,exponent:4.5,trig:every(1/8)) pos=t*2 note=[g1,g2,g0,b2][pos] accent=[.7k,21.8k,.8k,.4k, .7k,12.8k,2.8k,.4k][pos]*.5 slide=[1.8,.03,.8,.01, 1.8,.8,1.8,.03][pos] ramp(note |> slew($,slide,.1,exp:2)) |> diodeladder($, cutoff:400+(accent |> slew($,.08,.06,3))*envelope, q:.93, k:0.0025, sat:.9) |> out($*.5) ``` -------------------------------- ### Simple Attack-Decay Envelope Source: https://loopmaster.xyz/tutorials/zero-to-hero Shape the volume of a sound over time using an Attack-Decay envelope. Triggered by an impulse, it controls amplitude changes from initial attack to decay. ```js sine(a4) * ad(trig:every(1/2)) |> out($) ``` -------------------------------- ### Iterate Over Range with for...in Loop Source: https://loopmaster.xyz/tutorials/zero-to-hero Use a 'for...in' loop to iterate over a range of numbers. The range is inclusive of the end value. ```js for (i in 0..3) saw(#scale[i*2]*o4)/3 |> out($) ``` -------------------------------- ### Basic Gaussian Noise for Hihats Source: https://loopmaster.xyz/tutorials/making-a-house-loop Generates basic gaussian noise, serving as the raw material for hihat sounds. This is very loud and needs to be attenuated. ```loop gauss() |> out($*.5) ``` -------------------------------- ### All Drum Sounds Together Source: https://loopmaster.xyz/tutorials/drum-one-liners Combines all previously defined drum sounds into a single sequence. Includes BPM and transpose settings. ```loopmaster bpm=144 transpose=-3 trig=tram('x-x-x-x-') sine(#1*o2+100k*ad(.0009,.012,500,trig),trig)*ad(.0014,.5,8,trig) |> out($) trig=tram('-x',1/4) gauss(98,trig)*ad(.006,.32,4,trig) |> hps($,12k,.75) |> out($) trig=tram('xx-X',1/4) gauss(5,trig)*ad(.001,.09,4,trig) |> hps($,12k,.75)*.1 |> out($) trig=tram('-x--',1/2) ;(white(11,trig)+tri(#3*o2)*1)*ad(.001,.24,28,trig)*.9 |> bps($,1.8k,.5) |> out($) trig=tram('---x',1/2) ;(white(17,trig)+tri(#3*o2,trig)*1)*ad(.001,.5,28,trig) |> bps($,.6k,.9) |> bps($,1.4k,.75) |> bps($,7k,.7) |> clamp($*100,-1,.1)*.2 |> out($) trig=tram('-x-x-x-[xxx]') sine([180,300,500].random(every(1/16)))*ad(.001,.02,trig)*.3 |> out($) ``` -------------------------------- ### Attack-Decay Envelope with Exponent Curve Source: https://loopmaster.xyz/tutorials/zero-to-hero Apply an exponential curve to the Attack-Decay envelope using the 'exponent' parameter. This allows for non-linear shaping of the sound's amplitude. ```js sine(a4) * ad(attack:0.001, decay:0.9, exponent:10, trig:every(1/2)) |> out($) ``` -------------------------------- ### Create Rhythmic Patterns with tram Source: https://loopmaster.xyz/tutorials/zero-to-hero Generates a rhythmic pattern using the 'tram' function for triggering events. Adjust the pattern string and timing as needed. ```javascript sine(e4) * ad(0.001, 0.9,10, trig:tram('x-xx-',1/2)) |> out($) ``` -------------------------------- ### Play Chords using Roman Numerals Source: https://loopmaster.xyz/tutorials/zero-to-hero Defines and plays chords using Roman numeral notation (#i to #vii) for scale degrees, offering a music-theory-aligned approach. ```javascript scale = 'minor' chord = [#i, #iii, #v, #vii][t]*o4 chord.map(saw).avg() * ad(trig:euclid(5, 8, bar:1/2)) |> out($) ``` -------------------------------- ### Generate Bongo Sound Source: https://loopmaster.xyz/tutorials/drum-one-liners This snippet generates a bongo sound using a sine wave with randomized frequencies and an amplitude envelope. ```loopmaster trig=tram('-x-x-x-[xxx]') sine([180,300,500].random(every(1/16)))*ad(.001,.02,trig)*.3 |> out($) ``` -------------------------------- ### Generate Melody Notes from Scale Degrees Source: https://loopmaster.xyz/tutorials/zero-to-hero Creates a melody by selecting notes from a specified scale using degree numbers (#1 to #9) and octave multiplier (o4). ```javascript scale = 'minor' melody = [#1, #3, #5, #7, #9]*o4 saw(melody[t]) * ad(trig:euclid(5, 8, bar:1/2)) |> out($) ``` -------------------------------- ### Basic Ramp Oscillator Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Outputs the raw sound of the ramp oscillator without any filtering. This serves as a baseline for understanding subsequent sound shaping. ```js ramp(a1) |> out($) ``` -------------------------------- ### Use Variables for Frequency and Volume Source: https://loopmaster.xyz/tutorials/zero-to-hero Assigns values to variables `hz` and `vol` and uses them to control the frequency and amplitude of a sine wave. ```javascript hz = 330 vol = 0.5 sine(hz) * vol |> out($) ``` -------------------------------- ### Function with Default Parameter Source: https://loopmaster.xyz/tutorials/zero-to-hero Assign default values to parameters using `= value`. If an argument for such a parameter is not provided during function call, the default value is used. ```js add = (x, y = 10) -> x + y print(add(5)) print(add(5, 7)) ``` -------------------------------- ### Generate Rhythms with euclid Pattern Generator Source: https://loopmaster.xyz/tutorials/zero-to-hero Utilizes the 'euclid' function to create complex rhythmic patterns. The parameters control the number of pulses and the total steps. ```javascript tri(e4) * ad(0.01, 0.9,15, trig:euclid(3, 8, bar:1/2)) |> out($/2) ``` ```javascript tri(c4) * ad(0.01, 0.9,15, trig:euclid(3, 8, 1, bar:1/2)) |> out($/2) ``` ```javascript drums() |> out($) ``` -------------------------------- ### Generate Open Hi-Hat Sound Source: https://loopmaster.xyz/tutorials/drum-one-liners This snippet creates an open hi-hat sound using a Gaussian noise generator and an amplitude envelope, with high-pass filtering. ```loopmaster trig=tram('-x',1/4) gauss(98,trig)*ad(.006,.32,4,trig) |> hps($,12k,.75) |> out($) ``` -------------------------------- ### Layering Sawtooth Waves for Richer Chords Source: https://loopmaster.xyz/tutorials/making-a-house-loop This snippet creates a richer chord sound by layering two sawtooth waves with a frequency ratio of 1.5 (a perfect fifth). It averages the results and normalizes amplitude. ```loopmaster trig=tram('-x',1/4) ;[e3,a3,c4].map(hz->saw(hz)+saw(hz*1.5)).avg()/2*ad(attack:.05,decay:.4,trig) |> out($*.2) ``` -------------------------------- ### Generate Kick Drum Sound Source: https://loopmaster.xyz/tutorials/drum-one-liners Use this snippet to create a basic kick drum sound. It utilizes a sine wave modulated by an amplitude envelope. ```loopmaster trig=tram('x-x-x-x-') sine(52+100k*ad(.0009,.012,500,trig),trig)*ad(.0014,.5,8,trig) |> out($) ``` -------------------------------- ### Basic Square Oscillator Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Outputs the raw sound of the square oscillator without any filtering. This provides a comparison to the ramp oscillator's harmonic content. ```js sqr(a1) |> out($) ``` -------------------------------- ### Generate Triangle Wave Sound Source: https://loopmaster.xyz/tutorials/zero-to-hero Generates a 330Hz triangle wave and outputs it to the speakers. Triangle waves have a soft, flute-like quality. ```javascript tri(330) |> out($) ``` -------------------------------- ### Chained Conditions with else if Source: https://loopmaster.xyz/tutorials/zero-to-hero Handle multiple conditions sequentially using `else if`. The first condition that evaluates to true will have its corresponding code block executed. ```js (if (t % 4 < 1) saw(c4) else if (t % 4 < 2) tri(e4) else sqr(a4)) |> out($) ``` -------------------------------- ### Sync Sine Wave Phase to Beat Source: https://loopmaster.xyz/tutorials/making-a-house-loop Synchronizes the phase of the sine wave oscillator to the beat using the `trig` parameter. This ensures a consistent sound on each beat. ```loop trig=every(1/4) sine(hz:e1,trig)*ad(attack:.001,decay:.4,trig) |> out($) ``` -------------------------------- ### Define a Simple Function Source: https://loopmaster.xyz/tutorials/zero-to-hero Use the `->` operator to define a function that takes a single parameter and returns an expression. This is useful for creating concise, reusable logic. ```js double = x -> x * 2 print(double(5)) print(double(21)) ``` -------------------------------- ### Complete House Loop Mix with Post-Processing Source: https://loopmaster.xyz/tutorials/making-a-house-loop This is the complete house loop combining multiple sound layers, filters, and effects. It includes a sine wave bass, a percussive element, a synth lead, and a low-frequency bassline, all processed with filters and a compressor/limiter. ```loopmaster bpm=128 trig=every(1/4) envelope=ad(attack:.006,decay:8,exponent:100,trig) sine(hz:e1+100*envelope,trig)*envelope |> hp($,cutoff:80,q:1) |> peak($,cutoff:400,q:.5,gain:-10) |> out($*.5) trig=tram('xxXx',1/4) gauss(seed:4343,trig)*ad(attack:.002,decay:.03,trig) |> hp($,cutoff:11k) |> out($*.08) trig=tram('-x',1/2); (gauss(seed:2,trig)+tri(hz:a2))*ad(attack:.0004,decay:.075,e:2.4,trig) |> bp($,cutoff:2000) |> out($) ;[e1,a1].glide(1/2) |> tri($) |> lp($,cutoff:70,q:.9) |> out($*.3) trig=tram('-x',1/4) ;[e3,a3,c4].map(hz->saw(hz)+saw(hz*1.5)).avg()/7*ad(attack:.05,decay:.4,trig) |> lps($,cutoff:200+700*ad(attack:.01,decay:.5,trig),q:.5) |> $+dattorro($)*1.75 |> out($) mix=>compressor($) |> limiter($) ``` -------------------------------- ### ADSR Envelope with Sustain and Release Source: https://loopmaster.xyz/tutorials/zero-to-hero Utilize an ADSR (Attack-Decay-Sustain-Release) envelope for more complex volume shaping. It includes sustain level and release time parameters. ```js sine(a3) * adsr( attack:0.01, decay:0.1, sustain:.4, release:0.4, trig:sustain(.4,every(1/2)) ) |> out($) ``` -------------------------------- ### Additive Synthesis: Creating a Sawtooth Wave Source: https://loopmaster.xyz/tutorials/sound-synthesis-101 Generates a sawtooth wave by adding multiple sine wave harmonics with varying amplitudes. Adjusting harmonic volumes changes the timbre. ```javascript f = 110 // fundamental frequency sine(f)*0.99 // 1st harmonic + sine(f*2)*0.50 // 2nd harmonic (octave) + sine(f*3)*0.33 // 3rd harmonic + sine(f*4)*0.25 // ... + sine(f*5)*0.20 + sine(f*6)*0.16 + sine(f*7)*0.14 + sine(f*8)*0.12 + sine(f*9)*0.11 + sine(f*10)*0.09 |> out($*.1) ``` -------------------------------- ### Consistent Hihat Sound with Seeded Noise Source: https://loopmaster.xyz/tutorials/making-a-house-loop Ensures the hihat sound is consistent across plays by using a fixed seed for the gaussian noise generator. Without a seed, each trigger would produce different noise. ```loop trig=tram('xxXx',1/4) gauss(seed:4343,trig)*ad(attack:.002,decay:.03,trig) |> out($*.5) ``` -------------------------------- ### Shorthand and Named Arguments Mix Source: https://loopmaster.xyz/tutorials/zero-to-hero Combine shorthand (variable names directly) and named arguments. They can be mixed and do not need to follow the defined parameter order. ```js damping = 0.4 decay = 0.6 sd() |> velvet($, decay, damping, room: 0.8) |> out($) ``` -------------------------------- ### Explicit Return in Function Source: https://loopmaster.xyz/tutorials/zero-to-hero Use the `return` keyword to exit a function early and specify a return value, especially useful in conditional logic within function blocks. ```js sawOrSine = hz -> { if (hz < 500) return saw(hz) else return sine(hz) } sawOrSine(300) |> out($) // move the knob above 500 to hear the sine ``` -------------------------------- ### Conditional Iteration with while Loop Source: https://loopmaster.xyz/tutorials/zero-to-hero Execute a block of code repeatedly as long as a specified condition is true. Ensure the condition eventually becomes false to avoid infinite loops. ```js i = 0 while (i < 3) { saw(#scale[i*2]*o4)/3 |> out($) i += 1 } ``` -------------------------------- ### Define Function with Multiple Statements Source: https://loopmaster.xyz/tutorials/zero-to-hero For more complex logic, use curly braces `{}` to enclose multiple statements and expressions within a function. The last expression is implicitly returned. ```js multiplyAdd = (x, y, z) -> { result = x * y result + z } print(multiplyAdd(3, 4, 30)) ``` -------------------------------- ### Ramp Oscillator with Filter Tweaks Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Fine-tunes the diode ladder filter's parameters, including cutoff, resonance (q), and saturation (sat), to add character to the ramp oscillator's sound. ```js ramp(a1) |> diodeladder($, cutoff:500, q:1, k:0, sat:1) |> out($) ``` -------------------------------- ### Generate Square Wave Sound Source: https://loopmaster.xyz/tutorials/zero-to-hero Generates a 220Hz square wave and outputs it to the speakers. Square waves produce a hollow and metallic sound. ```javascript sqr(220) |> out($) ``` -------------------------------- ### Dattorro Reverb Effect Source: https://loopmaster.xyz/tutorials/zero-to-hero Apply the Dattorro reverb algorithm for a spacious and rich sound. This effect simulates the acoustics of a room using multiple delays with high feedback. ```js saw(e4)*ad(trig:every(1/2)) |> $+dattorro($) |> out($) ``` -------------------------------- ### Flanger Effect Application Source: https://loopmaster.xyz/tutorials/zero-to-hero Apply a flanger effect, similar to chorus but with a single delay line and high feedback, creating a sweeping, resonant sound. Parameters control modulation rate, depth, and feedback. ```js saw(e4)*ad(trig:every(1/2)) |> $+flanger($, rate:0.25, depth:0.006, base:0.02, feedback:0.7) |> out($) ``` -------------------------------- ### Trigger Drum Sounds with tram Patterns Source: https://loopmaster.xyz/tutorials/zero-to-hero Uses the 'tram' function to create specific rhythmic patterns for drum sounds. Each pattern string defines the timing of hits. ```javascript bd(trig:tram('x-x-x-x-')) |> out($) ``` ```javascript ch(trig:tram('xxxxxx[xx]x',1/2)) |> out($) ``` ```javascript oh(trig:tram('-x-x-x-x')) |> out($) ``` ```javascript sd(trig:tram('--x---x-')) |> out($) ``` -------------------------------- ### Chorus Effect Application Source: https://loopmaster.xyz/tutorials/zero-to-hero Apply a chorus effect, which uses multiple short, modulated delays to create a thicker, richer sound. Parameters control the number of voices, modulation rate, and depth. ```js saw(e4)*ad(trig:every(1/2)) |> $+chorus($, voices:3, base:0.02, depth:0.006, rate:0.25, spread:0.5) |> out($) ``` -------------------------------- ### Snare Drum with Noise, Tone, and Bandpass Filter Source: https://loopmaster.xyz/tutorials/making-a-house-loop Constructs a snare drum sound by combining gaussian noise and a pitched triangle wave, shaped by an envelope and filtered with a bandpass filter to emphasize mid frequencies. ```loop trig=tram('-x',1/2); (gauss(seed:2,trig)+tri(hz:a2))*ad(attack:.0004,decay:.075,e:2.4,trig) |> bp($,cutoff:2000) |> out($) ``` -------------------------------- ### Adding Reverb to the Chord Source: https://loopmaster.xyz/tutorials/making-a-house-loop This snippet adds a Dattorro reverb effect to the existing layered sawtooth waves, providing space and depth to the sound. The reverb is scaled by 1.75. ```loopmaster trig=tram('-x',1/4) ;[e3,a3,c4].map(hz->saw(hz)+saw(hz*1.5)).avg()/7*ad(attack:.05,decay:.4,trig) |> lps($,200+700*ad(attack:.01,decay:.5,trig),.5) |> $+dattorro($)*1.75 |> out($) ``` -------------------------------- ### Generate Snare Drum Sound Source: https://loopmaster.xyz/tutorials/drum-one-liners Create a snare drum sound using a combination of white noise and a triangle wave, with multiple band-pass filters and a final clamp and volume adjustment. ```loopmaster trig=tram('---x',1/2) ;(white(17,trig)+tri(#3*o2,trig)*1)*ad(.001,.5,28,trig) |> bps($,.6k,.9) |> bps($,1.4k,.75) |> bps($,7k,.7) |> clamp($*100,-1,.1)*.2 |> out($) ``` -------------------------------- ### Punchy Kick Drum with FM and Exponential Envelope Source: https://loopmaster.xyz/tutorials/making-a-house-loop Introduces frequency modulation using an exponential amplitude envelope to create a punchier and more realistic kick drum sound. The output is also attenuated by 0.5. ```loop trig=every(1/4) envelope=ad(attack:.006,decay:8,exponent:100,trig) sine(hz:e1+100*envelope,trig)*envelope |> out($*.5) ``` -------------------------------- ### Generate Sawtooth Wave Sound Source: https://loopmaster.xyz/tutorials/zero-to-hero Generates a 440Hz sawtooth wave and outputs it to the speakers. Sawtooth waves have a bright and buzzy character. ```javascript saw(440) |> out($) ``` -------------------------------- ### Iterate Over Array with for...of Loop Source: https://loopmaster.xyz/tutorials/zero-to-hero Use a 'for...of' loop to iterate through elements of an array. This is suitable for processing each item in a collection. ```js for (note of [c4, e4, g4, a4]) saw(note)/4 |> out($) ``` -------------------------------- ### Conditional Execution with switch Statement Source: https://loopmaster.xyz/tutorials/zero-to-hero Execute different blocks of code based on the value of an expression. The 'default' case handles values that do not match any specific 'case'. ```js switch (floor(t % 4)) { case 0: sine(c4) case 1: tri(e4) case 2: saw(a4) default: sqr(e4) } |> out($) ``` -------------------------------- ### Hihat with Attack-Decay Envelope Source: https://loopmaster.xyz/tutorials/making-a-house-loop Shapes the gaussian noise with an attack-decay envelope to create a percussive hihat sound. The `tram('xxXx',1/4)` function provides a rhythmic trigger pattern. ```loop trig=tram('xxXx',1/4) gauss()*ad(attack:.002,decay:.03,trig) |> out($*.5) ``` -------------------------------- ### Fat Arrow Shorthand for Piped Functions Source: https://loopmaster.xyz/tutorials/zero-to-hero Use the `=>` operator as a shorthand for functions that take a single argument and immediately pipe it to another function. This simplifies common piping patterns. ```js synth => sine($/2+sine($/8)*$) |> lp($) synth(440) |> out($) ``` -------------------------------- ### Lowpass Filter Application Source: https://loopmaster.xyz/tutorials/zero-to-hero Apply a lowpass filter to attenuate high frequencies, allowing lower frequencies to pass through. This is a fundamental technique in subtractive synthesis. ```js saw(e4) |> lp($) |> out($) ``` -------------------------------- ### Applying a Lowpass Filter Sweep Source: https://loopmaster.xyz/tutorials/making-a-house-loop This code applies a lowpass filter with a sweeping cutoff frequency controlled by an AD envelope, creating a classic house filter sweep effect. Resonance is set to 0.5. ```loopmaster trig=tram('-x',1/4) ;[e3,a3,c4].map(hz->saw(hz)+saw(hz*1.5)).avg()/7*ad(attack:.05,decay:.4,trig) |> lps($,cutoff:200+700*ad(attack:.01,decay:.5,trig),q:.5) |> out($) ``` -------------------------------- ### TB-303 Bassline Melody Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Generates a bassline melody by sequencing notes and applying the diode ladder filter modulated by an envelope. Adjust decay and cutoff for different melodic characteristics. ```js envelope=ad(attack:.001,decay:1,exponent:4.5,trig:every(1/8)) ramp([g1,g2,g0,b2][t*2]) |> diodeladder($, cutoff:100+1k*envelope, q:.9, k:0, sat:.9) |> out($*.5) ``` -------------------------------- ### Ramp Oscillator with Diode Ladder Filter Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Applies the diode ladder filter to the ramp oscillator. This demonstrates the initial effect of filtering on the harmonic spectrum, resulting in a slightly muddier sound. ```js ramp(a1) |> diodeladder($) |> out($) ``` -------------------------------- ### Generate Rimshot Sound Source: https://loopmaster.xyz/tutorials/drum-one-liners This snippet produces a rimshot sound by combining white noise and a triangle wave, processed with an amplitude envelope and band-pass filtering. ```loopmaster trig=tram('---x',1/2) ;(white(11,trig)+tri(#3*o2)*1)*ad(.001,.24,28,trig)*.9 |> bps($,1.8k,.5) |> out($) ``` -------------------------------- ### Apply LFO to Filter Cutoff Source: https://loopmaster.xyz/tutorials/zero-to-hero Modulates the filter cutoff frequency using a triangle LFO. Ensure the LFO function is available in your environment. ```javascript saw(c1) |> lp($, cutoff:100+2000*lfotri(2), q:3) |> out($) ``` -------------------------------- ### Generate Closed Hi-Hat Sound Source: https://loopmaster.xyz/tutorials/drum-one-liners Use this for a closed hi-hat sound. It employs a Gaussian noise generator, amplitude envelope, and high-pass filtering, with a slight volume reduction. ```loopmaster trig=tram('xx-X',1/4) gauss(5,trig)*ad(.001,.09,4,trig) |> hps($,12k,.75)*.1 |> out($) ``` -------------------------------- ### Kick Drum with Amplitude Envelope Source: https://loopmaster.xyz/tutorials/making-a-house-loop Adds an attack-decay envelope to shape the amplitude of the sine wave, creating a fading sound. The `trig:every(1/4)` parameter ensures the envelope triggers rhythmically. ```loop sine(hz:e1)*ad(attack:.001,decay:.4,trig:every(1/4)) |> out($) ``` -------------------------------- ### Shadow Outer Scope Variable with Local Assignment Source: https://loopmaster.xyz/tutorials/zero-to-hero Illustrates using the `:=` operator to create a local variable within a function that shadows an outer scope variable, leaving the outer variable unchanged. ```javascript x = 10 dontChangeIt = () -> { x := 42 // local x, outer x remains untouched } print(x) dontChangeIt() print(x) // still 10 ``` -------------------------------- ### Mute Other Signals with 'solo' Source: https://loopmaster.xyz/tutorials/zero-to-hero Mutes all other signals currently sent to 'out', allowing selective listening to specific parts of the mix. Can be used multiple times. ```javascript saw(e4)*ad(trig:every(1/2)) |> solo($) ``` -------------------------------- ### Deep Sub-Bass with Lowpass Filter Source: https://loopmaster.xyz/tutorials/making-a-house-loop Applies a lowpass filter to the bass sound to create a deep sub-bass tone by removing all frequencies above 70 Hz. ```loop ;[e1,a1].glide(1/2) |> tri($) |> lp($,cutoff:70,q:.9) |> out($*.5) ``` -------------------------------- ### Delay Effect with Feedback Source: https://loopmaster.xyz/tutorials/zero-to-hero Enhance the delay effect by using feedback, which re-applies the delay to the echo itself. This creates repeating, decaying echoes. ```js saw(e4)*ad(trig:every(1/2)) |> $+delay($, seconds:0.25, feedback:0.5) |> out($) ``` -------------------------------- ### Ternary Operator for Concise Conditionals Source: https://loopmaster.xyz/tutorials/zero-to-hero Use the ternary operator `? :` as a shorthand for simple `if-else` statements. It's useful for assigning values or choosing between two expressions based on a condition. ```js (t % 4 < 1 ? saw(c4) : t % 4 < 2 ? tri(e4) : sqr(a4)) |> out($) ``` -------------------------------- ### Full TB-303 Sound with Distortion Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Adds a `tanh` distortion effect to the TB-303 sound, completing the classic acid bassline. The distortion is applied after the filter and envelope stages. ```js envelope=ad(attack:.001,decay:1,exponent:12.5,trig:every(1/8)) pos=t*2 note=[g1,g2,g0,b2][pos] accent=[.7k,21.8k,.8k,.4k, .7k,12.8k,2.8k,.4k][pos]*.5 slide=[1.8,.03,.8,.01, 1.8,.8,1.8,.03][pos] ramp(note |> slew($,slide,.1,exp:2)) |> diodeladder($, cutoff:400+(accent |> slew($,.08,.06,3))*envelope, q:.93, k:0.0025, sat:.9 ) |> tanh($*25) |> out($*.15) ``` -------------------------------- ### Envelope: Modulating Sine Wave Frequency Source: https://loopmaster.xyz/tutorials/sound-synthesis-101 Uses an attack-decay envelope to modulate the frequency of a sine wave, creating a pitch drop effect. This is used to simulate a kick drum sound. ```javascript env = ad(attack:0.001, decay:0.5, exponent:10, trig:every(1/2)) sine(c1 + 200*env) * env |> out($) ``` -------------------------------- ### Bright Hihat with Highpass Filter Source: https://loopmaster.xyz/tutorials/making-a-house-loop Applies a highpass filter to the hihat sound to remove low frequencies, resulting in a crisp and bright tone characteristic of hihats. ```loop trig=tram('xxXx',1/4) gauss(seed:4343,trig)*ad(attack:.002,decay:.03,trig) |> hp($,cutoff:11k) |> out($*.5) ``` -------------------------------- ### Subtractive Synthesis: Filtering a Sawtooth Wave Source: https://loopmaster.xyz/tutorials/sound-synthesis-101 Applies a low-pass filter to a sawtooth wave to create a simpler sound. Tweak the cutoff frequency to alter the brightness. ```javascript saw(a1) |> lp($, cutoff:500) |> out($) ``` -------------------------------- ### Update Outer Scope Variable Source: https://loopmaster.xyz/tutorials/zero-to-hero Demonstrates how assigning a value to a variable within a function updates an existing variable in the outer scope. ```javascript x = 10 changeOuterX = () -> { x = 42 // finds outer x and updates it } print(x) changeOuterX() print(x) // updated outer x ``` -------------------------------- ### Filtered Kick Drum for Professional Sound Source: https://loopmaster.xyz/tutorials/making-a-house-loop Applies highpass and peak filters to the kick drum sound for a cleaner, more professional tone. The highpass filter removes low frequencies, and the peak filter reduces boxiness. ```loop trig=every(1/4) envelope=ad(attack:.006,decay:8,exponent:100,trig) sine(hz:e1+100*envelope,trig)*envelope |> hp($,cutoff:80,q:1) |> peak($,cutoff:400,q:.5,gain:-10) |> out($*.5) ``` -------------------------------- ### FM Synthesis: Modulating a Sine Wave Source: https://loopmaster.xyz/tutorials/sound-synthesis-101 Creates a complex sound by modulating the frequency of a carrier sine wave with a modulator sine wave. Adjust frequency and modulation index for different timbres. ```javascript f = 60 |> ntof($) mi = 1.0 sine(f + sine(f)*f*mi) |> out($) ``` -------------------------------- ### Abbreviated Named Arguments Source: https://loopmaster.xyz/tutorials/zero-to-hero Named arguments can be abbreviated as long as they are unique and unambiguous among the function's parameters. This offers a concise way to specify arguments. ```js sd() |> velvet($, dec: 0.6, damp: 0.4, r: 0.8) |> out($) ``` -------------------------------- ### Envelope: Modulating Filter Cutoff Source: https://loopmaster.xyz/tutorials/sound-synthesis-101 Applies an attack-decay envelope to the cutoff frequency of a low-pass filter applied to a sawtooth wave. This dynamically changes the brightness of the sound over time. ```javascript env = ad(attack:0.0001, decay:0.5, exponent:5, trig:every(1/2)) saw(a1) * env |> lp($, cutoff:200 + 5000*env) |> out($) ``` -------------------------------- ### Ramp Oscillator with LFO Filter Modulation Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Modulates the filter's cutoff frequency over time using a low-frequency oscillator (LFO) to introduce movement and the characteristic 'acid' sound. ```js ramp(a1) |> diodeladder($, cutoff:100+10k*lfotri(1)**3, q:.8, k:0, sat:1) |> out($) ``` -------------------------------- ### Ramp Oscillator with Envelope Filter Modulation Source: https://loopmaster.xyz/tutorials/tb303-from-scratch Shapes the filter's cutoff frequency using an ADSR envelope, creating a more dynamic and TB-303-like sound compared to LFO modulation. ```js envelope=ad(attack:.001,decay:1,exponent:10,trig:every(1/4)) ramp(a1) |> diodeladder($, cutoff:100+10k*envelope, q:.8, k:0, sat:1) |> out($) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.