### Initialization and Setup Source: https://github.com/gibber-cc/gibberish/blob/v3/README.markdown Explains how to initialize the Gibberish audio engine within a browser environment. ```APIDOC ## Initialization ### Description Initializes the Gibberish audio engine and exports library functions to the global scope. ### Method POST ### Endpoint Gibberish.init() ### Request Body - **workletPath** (string) - Required - Path to the gibberish_worklet.js file. ### Request Example { "workletPath": "dist/gibberish_worklet.js" } ### Response #### Success Response (200) - **status** (string) - Returns a promise that resolves when the audio context is ready. #### Response Example { "status": "initialized" } ``` -------------------------------- ### Generated Audio Callback Example Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md An example of the low-level audio callback structure generated when using the SSD unit. ```javascript var v_34 = ssd_out_33( memory ) var v_36 = v_34 * 100 var v_37 = 440 + v_36 var v_38 = sine_38( v_37, 1, memory ) var v_20 = bus2_20( 0, v_38, memory ) var v_35 = ssd_in_33( v_38, memory ) return v_20 ``` -------------------------------- ### PolySynth Example: Creating and Playing Chords Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates how to instantiate a PolySynth with a specified number of voices and play a chord. PolySynth allows multiple voices to play simultaneously, with each voice being managed independently. ```javascript a = PolySynth({ maxVoices:3 }).connect() a.chord([ 330,440,550 ]) ``` -------------------------------- ### Gibberish: Full Track Example with Synthesis and Sequencing Source: https://context7.com/gibber-cc/gibberish/llms.txt A comprehensive example showcasing multiple Gibberish features working together to create a full music track. It includes initialization, exporting to the window, global reverb, bassline synthesis with filter modulation, drum sequencing, and polyphonic pads with chorus effects. ```javascript Gibberish.workletPath = 'dist/gibberish_worklet.js' Gibberish.init().then(() => { Gibberish.export(window) beat = 22050 // Quarter note at 44.1kHz // Global reverb verb = Freeverb({ input: Bus2(), roomSize: 0.975, damping: 0.5 }).connect() // Bassline with filter modulation bass = Synth({ gain: 0.15, attack: 44, decay: 5512, Q: 0.8, filterType: 2, saturation: 2, filterMult: 3.25, antialias: true, cutoff: Add(1, Sine({ frequency: 0.1, gain: 0.75 })) }) .connect() .connect(verb.input, 0.5) bassSeq = Sequencer.make([55, 110, 165, 220], [beat / 4], bass, 'note').start() // Drums kick = Kick().connect() kickSeq = Sequencer({ target: kick, key: 'trigger', values: [0.75, 0.5, 0.75, 0.75], timings: [beat * 0.75, beat * 0.25, beat, beat] }).start() snare = Snare().connect(verb.input, 0.5).connect(Gibberish.output, 0.75) snareSeq = Sequencer.make([1], [beat * 2], snare, 'trigger').start(beat) hat = Hat().connect() hatSeq = Sequencer.make([0.075], [beat / 4], hat, 'trigger').start() // Polyphonic pads with chorus chords = PolySynth({ attack: 44, decay: beat * 10, gain: 0.075, maxVoices: 6, waveform: 'pwm', pulsewidth: Add(0.35, Sine({ frequency: 0.35, gain: 0.3 })) }).connect() chorus = Chorus({ input: chords, slowGain: 8, fastFrequency: 4 }) .connect(verb.input) chordsSeq = Sequencer({ target: chords, key: 'chord', values: [ [440, 550, 660], [440 * 1.25, 550 * 1.25, 660 * 1.25], [440 * 0.8, 550 * 0.8, 660 * 0.8] ], timings: [beat * 16] }).start() }) ``` -------------------------------- ### Implement Envelope Following with Follow Ugen Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md This example demonstrates how to use the Follow Ugen to track the output of a Karplus-Strong synthesis unit. The tracked signal is then used to modulate the frequency of a Sine oscillator. ```javascript trackedUgen = Karplus({ gain:2 }).connect(); Sequencer({ target:trackedUgen, key:'note', values:[440,880], timings:[22050] }).start(); tracker = Follow({ input: trackedUgen }); // modulate sine frequency based on tracked Karplus plucking Sine({ frequency:Add( 440, Mul( tracker,220 ) ), gain:.25 }).connect(); ``` -------------------------------- ### Initialize and Use Gibberish Distortion Effect Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md This example shows the initialization of a Distortion effect using the Karplus instrument in Gibberish. It highlights the use of `pregain` and `postgain` properties to control the intensity and output level of the distortion. The effect is then connected and a note is played. ```javascript syn = Gibberish.instruments.Karplus({ attack:44 }) dist = Gibberish.effects.Distortion({ input:syn, pregain:100, postgain:.25, }).connect() syn.note( 440 ) ``` -------------------------------- ### Filter24Classic Example - Gibberish JavaScript Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Presents the Filter24Classic, a 24dB-per-octave resonant filter. The example initializes a Synth and connects a Filter24Classic to it, specifying the cutoff frequency modulated by a Sine wave and a Q factor. The filter is then connected to the output, and the synth is triggered. ```javascript syn = Gibberish.instruments.Synth({ attack:44, decay:44100 * 4 }) filter = Gibberish.filters.Filter24Classic({ input:syn, cutoff: Add( .2, Sine({ frequency:2, gain:.15 }) ), Q: .25, }).connect() syn.note( 220 ) ``` -------------------------------- ### Synth Instrument and Sequencing Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Provides an example of configuring a Synth instrument with specific waveform and filter settings, and using a Sequencer to trigger notes. ```javascript syn = Gibberish.instruments.Synth({ waveform: 'saw', filterType: 3, filterMult: 1760, Q: 9, attack:44, decay:11025, gain:.1 }).connect() Gibberish.Sequencer({ target:synth, key:'note', values:[ 110 ], timings:[ 22050 ] }).start() ``` -------------------------------- ### Filter12Biquad Example - Gibberish JavaScript Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates the Filter12Biquad, a 12dB-per-octave resonant biquad filter. The example initializes a Synth, then creates a Filter12Biquad instance connected to the synth. It showcases setting the filter's mode (0 for lowpass), cutoff frequency modulated by a Sine wave, and Q factor, before connecting the filter to the output and triggering the synth. ```javascript syn = Gibberish.instruments.Synth({ attack:44, decay:44100 * 4 }) filter = Gibberish.filters.Filter12Biquad({ input:syn, mode:0, cutoff: Add( .5, Sine({ frequency:2, gain:.5 }) ), Q: .5, }).connect() syn.note( 220 ) ``` -------------------------------- ### Filter12SVF Example - Gibberish JavaScript Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Illustrates the Filter12SVF, a 12dB-per-octave resonant filter. The example sets up a Synth and then a Filter12SVF instance connected to it. It configures the filter's mode (1 for highpass), a cutoff frequency modulated by a Sine wave, and the Q factor, then connects the filter and plays a note. ```javascript syn = Gibberish.instruments.Synth({ attack:44, decay:44100 * 4 }) filter = Gibberish.filters.Filter12SVF({ input:syn, mode:1, cutoff: Add( .5, Sine({ frequency:2, gain:.25 }) ), Q: .5, }).connect() syn.note( 220 ) ``` -------------------------------- ### Ramp Generator Example - Gibberish JavaScript Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Shows how to use the Ramp generator to create a linear value change over time, with options for looping. The example connects a Sine wave oscillator and modulates its frequency using a Ramp instance, setting custom 'from', 'to', and 'length' values, and enabling looping. ```javascript a = Sine().connect() a.frequency = Ramp({ from:220, to:440, length:22050, shouldLoop:true }) ``` -------------------------------- ### Configuring FM Synthesis Sequencers in Gibberish.js Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md This example shows how to set up multiple sequencers for the FM synthesizer in Gibberish.js. It configures sequencers for carrier-modulator ratio, modulation index, and note frequency, with randomized values for ratio and index. ```javascript fm = Gibberish.instruments.FM({ modulatorWaveform:'square', // or saw, sine etc. }).connect() Gibberish.Sequencer({ target:fm, key:'cmRatio', values:[ function() { return .15 + Math.random() * 10 } ], timings:[22050] }).start() Gibberish.Sequencer({ target:fm, key:'index', values:[ function() { return .5 + Math.random() * 20 } ], timings:[22050] }).start() Gibberish.Sequencer({ target:fm, key:'note', values:[ 440 ], timings:[ 44100 ] }).start() ``` -------------------------------- ### ADSR Envelope Example - Gibberish JavaScript Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md This snippet illustrates the ADSR (Attack-Decay-Sustain-Release) envelope, a four-stage envelope generator. While no direct code example is provided for ADSR's trigger or advance methods, its properties like attack, decay, sustain, sustainLevel, release, and triggerRelease are detailed. -------------------------------- ### Initialize and Use Gibberish Freeverb Effect Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md This example demonstrates how to initialize and use the Freeverb effect in Gibberish with a Synth instrument. It focuses on setting the `roomSize` property to control the reverberation amount. The effect is connected, and a note is triggered. ```javascript syn = Gibberish.instruments.Synth({ attack:44 }) verb = Gibberish.effects.Freeverb({ input:synth, roomSize:.95 }).connect() syn.note( 220 ) ``` -------------------------------- ### Sampler Instrument Playback Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Shows how to load an external audio file using the Sampler instrument and trigger playback once the file has loaded. The example includes playing the sample in reverse at a specific speed. ```javascript rhodes = Gibberish.instruments.Sampler({ filename:'http://127.0.0.1:25000/playground/resources/audiofiles/rhodes.wav' }).connect() rhodes.onload = function() { rhodes.note( -4 ) // play sample in reverse at 4x speed. } ``` -------------------------------- ### Effects API Source: https://context7.com/gibber-cc/gibberish/llms.txt Provides examples for various audio effects such as Reverb, Delay, Chorus, Distortion, BitCrusher, Flanger, Tremolo, and Vibrato. ```APIDOC ## Effects Audio effects including Reverb, Delay, Chorus, Distortion, BitCrusher, Flanger, Tremolo, and Vibrato. ### Example Usage ```javascript syn = Synth({ attack: 44, decay: 44100 }).connect() // Freeverb (Schroeder-Moorer reverb) reverb = Freeverb({ input: syn, roomSize: 0.9, // Reverb time (0-1) damping: 0.5, // High-frequency attenuation dry: 0.5, wet1: 1, wet2: 0 }).connect() // Dattorro Plate Reverb plate = Plate({ input: syn, decay: 0.8, damping: 0.5, predelay: 10 }).connect() // Delay with feedback delay = Delay({ input: syn, delayTime: 11025, // Samples feedback: 0.7, wetdry: 0.5 }).connect() // Arp Solina-style Chorus chorus = Chorus({ input: syn, slowFrequency: 0.18, slowGain: 2, fastFrequency: 4, fastGain: 1 }).connect() // Distortion dist = Distortion({ input: syn, pregain: 100, postgain: 0.25, shape1: 0, // Hard/soft clipping shape2: 0 }).connect() // BitCrusher crush = BitCrusher({ input: syn, sampleRate: 0.15, // Sample rate reduction bitCrusher: 0.5 // Bit depth reduction }).connect() // Flanger flanger = Flanger({ input: syn, frequency: 0.5, offset: 0.25, feedback: 0.7 }).connect() syn.note(440) ``` ``` -------------------------------- ### Gibberish.clear Source: https://context7.com/gibber-cc/gibberish/llms.txt Disconnects all unit generators from the master bus and stops all sequencers. Use this to reset the audio graph and start fresh. ```APIDOC ## Gibberish.clear Disconnects all unit generators from the master bus and stops all sequencers. Use this to reset the audio graph and start fresh. ```javascript // Create some audio kick = Kick().connect() seq = Sequencer.make([110], [22050], kick, 'note').start() // Later, clear everything Gibberish.clear() ``` ``` -------------------------------- ### Trigger Note with Kick Instrument Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Triggers a note on the Kick instrument with a specified loudness. This example uses a Sequencer to trigger the note at predefined intervals and loudness values. ```javascript kick = Gibberish.Kick({ frequency: 80 }).connect() Gibberish.Sequencer({ target:kick, key:'trigger', values:[ .1,.2,.3,.5], timings:[11025] }).start() ``` -------------------------------- ### AD Envelope Example - Gibberish JavaScript Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates the usage of the AD (Attack-Decay) envelope in Gibberish. This envelope creates a two-stage sound modulation with exponential attack and decay. It's initialized, connected to a Sine wave oscillator, and then triggered to play. ```javascript a = Sine() b = AD() c = Mul( a,b ) Gibberish.output.inputs.push( c ) b.trigger() ``` -------------------------------- ### Initialize and Use Gibberish Flanger Effect Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md This code snippet illustrates the setup of a Flanger effect in Gibberish, utilizing a standard Synth instrument. It demonstrates setting `delayTime` and `feedback` parameters for the modulated delay line. The effect is connected, and a note is played. ```javascript syn = Gibberish.instruments.Synth({ attack:44 }) delay = Gibberish.effects.Flanger({ input:synth, delayTime: 5512, feedback: .9 }).connect() syn.note( 220 ) ``` -------------------------------- ### Basic Oscillator Waveform Generation Source: https://context7.com/gibber-cc/gibberish/llms.txt Illustrates the creation and connection of basic waveform oscillators including Sine, Saw, Square, and Triangle. It also shows the setup for a PWM oscillator with adjustable pulse width and noise generators (white, pink, brown). ```javascript // Basic oscillators sine = Sine({ frequency: 440, gain: 0.5 }).connect() saw = Saw({ frequency: 220, gain: 0.3, antialias: true }).connect() square = Square({ frequency: 330, gain: 0.2 }).connect() triangle = Triangle({ frequency: 440, gain: 0.4 }).connect() // PWM oscillator with variable pulse width pwm = PWM({ frequency: 110, pulsewidth: 0.35, // 0.5 = square wave gain: 0.3 }).connect() // Noise generators white = Noise({ color: 'white', gain: 0.1 }).connect() pink = Noise({ color: 'pink', gain: 0.1 }).connect() brown = Noise({ color: 'brown', gain: 0.1 }).connect() // Modulate frequency with another oscillator modulated = Sine({ frequency: Add(440, Sine({ frequency: 5, gain: 20 })), gain: 0.5 }).connect() ``` -------------------------------- ### TR-808 Drum Instrument Emulation and Pattern Sequencing Source: https://context7.com/gibber-cc/gibberish/llms.txt Provides code for creating and triggering emulations of TR-808 drum sounds (Kick, Snare, Hat, Conga). It includes examples of triggering individual drums with frequency and loudness, and sequencing a classic drum pattern using the Sequencer. ```javascript // Create drum kit kick = Kick({ tone: 0.25, decay: 0.9 }).connect() snare = Snare({ decay: 0.1, snappy: 1, tune: 0 }).connect() hat = Hat({ decay: 0.05, tune: 0.5 }).connect() conga = Conga({ decay: 0.85 }).connect() // Trigger drums kick.note(90) // Kick with frequency kick.trigger(0.8) // Kick with loudness snare.trigger(0.5) hat.trigger(0.1) conga.note(440) // Classic drum pattern beat = 22050 // Quarter note at 44.1kHz kickSeq = Sequencer({ target: kick, key: 'trigger', values: [0.75, 0.5, 0.75, 0.75], timings: [beat * 0.75, beat * 0.25, beat, beat] }).start() snareSeq = Sequencer.make([1], [beat * 2], snare, 'trigger').start(beat) hatSeq = Sequencer.make([0.075], [beat / 4], hat, 'trigger').start() ``` -------------------------------- ### Initialize Synth and Sequencer in Gibberish Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates how to create a synthesizer instance and attach a sequencer to automate note changes over specific timing intervals. ```javascript syn = Gibberish.instruments.Synth({ attack:44, decay:22050, antialias:true }).connect() seq = Gibberish.Sequencer({ target: syn, key: 'note', values: [440,880,1760], timings: [11025, 22050 ], }).start() ``` -------------------------------- ### Initialize and Sequence Monosynth Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates how to instantiate a Monosynth with specific waveform, filter, and gain settings, and how to trigger it using a Gibberish sequencer. ```javascript mono = Gibberish.instruments.Monosynth({ waveform: 'saw', filterType: 2, filterMult: 1760, Q: 18, gain:.1 }).connect() Gibberish.Sequencer({ target:mono, key:'note', values:[ 110 ], timings:[ 44100 ] }).start() ``` -------------------------------- ### Initialize Gibberish in HTML Source: https://github.com/gibber-cc/gibberish/blob/v3/README.markdown Shows the standard boilerplate for including the Gibberish library and initializing the audio engine via the worklet path. ```html
``` -------------------------------- ### PolyFM Initialization and Chord Playback Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates how to instantiate a PolyFM synth with a specific voice count and trigger a chord. ```javascript a = PolyFM({ maxVoices:3 }).connect() a.chord([ 330,440,550 ]) ``` -------------------------------- ### Gibberish Initialization Source: https://context7.com/gibber-cc/gibberish/llms.txt Initializes the Gibberish audio engine, creating an AudioContext and connecting to the audio output. The `init()` method returns a Promise that resolves when the audio system is ready. Use `export()` to make Gibberish objects available in the global namespace for easier access. ```APIDOC ## Initialization Initializes the Gibberish audio engine, creating an AudioContext and connecting to the audio output. The `init()` method returns a Promise that resolves when the audio system is ready. Use `export()` to make Gibberish objects available in the global namespace for easier access. ```javascript // HTML setup ``` ``` -------------------------------- ### Connect Unit Generators in Gibberish Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates how to connect synthesizers to the master bus, custom buses, and effects using the ugen.connect method. It shows scaling output levels and routing multiple instruments into a single effect input. ```javascript syn = Gibberish.Synth() syn.connect() // default connection to master bus syn2 = Gibberish.Synth() bus = Gibberish.Bus2() // stereo bus bus.connect() // connect to master bus syn2.connect( bus ) // connect to bus syn3 = Gibberish.Synth() syn3.connect( bus, .5 ) // scale output to bus // By default, effects accept a single input. However, we can easily // connect multiple instruments to an effect using a bus as that input. reverb = Gibberish.Freeverb({ input:Bus() }).connect() syn.connect( reverb.input, .25 ) syn2.connect( reverb.input, .25 ) syn3.connect( reverb.input, .25 ) ``` -------------------------------- ### Trigger Chord with PolySynth Instrument Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Triggers a chord on the PolySynth instrument with a specified loudness. This example uses a Sequencer to trigger the chord at predefined intervals and loudness values. ```javascript syn = Gibberish.PolySynth({ attack:44, decay:22050 }).connect() syn.chord([ 330,440,550 ]) Gibberish.Sequencer({ target:syn, key:'trigger', values:[ .1,.2,.3,.5], timings:[11025] }).start() ``` -------------------------------- ### Gibberish: Create and Connect Audio Busses (Mono and Stereo) Source: https://context7.com/gibber-cc/gibberish/llms.txt Demonstrates the creation and usage of mono (Bus) and stereo (Bus2) audio busses for summing multiple audio signals. It shows how to connect individual sound sources to these busses and how to apply effects to the entire bus. ```javascript drumBus = Bus2().connect() // Connect drums to bus Kick().connect(drumBus) Snare().connect(drumBus, 0.5) Hat().connect(drumBus, 0.3) // Apply effect to entire bus reverb = Freeverb({ input: Bus2(), roomSize: 0.975 }).connect() bass = Synth({ gain: 0.15 }) .connect(Gibberish.output) // Dry signal .connect(reverb.input, 0.5) // Send to reverb lead = FM({ gain: 0.2 }) .connect() .connect(reverb.input, 0.3) ``` -------------------------------- ### FM Synthesizer Initialization and Modulation Source: https://context7.com/gibber-cc/gibberish/llms.txt Demonstrates the initialization of a two-operator FM synthesizer with configurable parameters like carrier-to-modulator ratio, modulation index, and feedback. It also shows how to dynamically modulate parameters using the Sequencer for creating evolving sounds. ```javascript fm = FM({ cmRatio: 2, // Carrier/modulator frequency ratio index: 5, // Modulation depth feedback: 0.001, // Modulator self-feedback (0-1) carrierWaveform: 'sine', modulatorWaveform: 'sine', filterType: 3, // TB-303 style filter cutoff: 0.35, Q: 0.5, attack: 44, decay: 22050, gain: 0.25 }).connect() // Dynamic parameter modulation Sequencer({ target: fm, key: 'cmRatio', values: [() => 0.15 + Math.random() * 10], timings: [22050] }).start() Sequencer({ target: fm, key: 'note', values: [110, 220, 165, 330], timings: [11025] }).start() ``` -------------------------------- ### Monosynth Initialization and Bassline Sequencing Source: https://context7.com/gibber-cc/gibberish/llms.txt Shows how to initialize a three-oscillator monosynth for rich bass and lead sounds, including detuning and filter settings. It demonstrates triggering notes and sequencing a bassline using the Sequencer. ```javascript mono = Monosynth({ waveform: 'saw', detune2: 1.01, // Second oscillator detuning detune3: 2.99, // Third oscillator detuning filterType: 2, // Moog-style ladder filter filterMult: 1760, Q: 0.8, gain: 0.1, attack: 44, decay: 22050 }).connect() mono.note(55) // Sequence a bassline Sequencer({ target: mono, key: 'note', values: [55, 110, 165, 220], timings: [5512] }).start() ``` -------------------------------- ### PolyMono Instrument Initialization Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates how to initialize a PolyMono instrument with a specific voice count and play a chord. The PolyMono object acts as a bus for multiple voices. ```javascript a = PolyMono({ maxVoices:3 }).connect() a.chord([ 330,440,550 ]) ``` -------------------------------- ### Initialize and Play PolyKarplus Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates how to instantiate a PolyKarplus instrument with a specified number of voices and trigger a chord. The maxVoices property must be set during initialization. ```javascript a = PolyKarplus({ maxVoices:3 }).connect(); a.chord([ 330,440,550 ]); ``` -------------------------------- ### Clear Gibberish Audio Graph Source: https://context7.com/gibber-cc/gibberish/llms.txt Resets the Gibberish audio graph by disconnecting all unit generators from the master bus and stopping all active sequencers. This is useful for cleaning up the audio state and starting a new session. ```javascript // Create some audio kick = Kick().connect() seq = Sequencer.make([110], [22050], kick, 'note').start() // Later, clear everything Gibberish.clear() ``` -------------------------------- ### Karplus Plucked String Synthesis Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates the initialization of the Karplus physical model and how to trigger notes with varying decay lengths. ```javascript pluck = Gibberish.Karplus().connect() pluck.note( 440 ) pluck.decay = 4 // seconds pluck.note( 440 ) ``` -------------------------------- ### Initialize Gibberish Audio Engine Source: https://context7.com/gibber-cc/gibberish/llms.txt Initializes the Gibberish audio engine, setting up the AudioContext and connecting to the audio output. It supports both AudioWorklet and ScriptProcessor modes. The initialization returns a Promise and can be configured with a worklet path. Exporting objects makes them globally accessible. ```html ``` ```javascript window.onload = function() { // Specify worklet path before initialization Gibberish.workletPath = 'dist/gibberish_worklet.js' // Initialize Gibberish (waits for user interaction in modern browsers) Gibberish.init().then(() => { // Export all Gibberish objects to window for easy access Gibberish.export(window) // Now you can use Sine(), Synth(), etc. directly Sine({ frequency: 440 }).connect() }) } ``` -------------------------------- ### Sampler for Loading and Playing Audio Files Source: https://context7.com/gibber-cc/gibberish/llms.txt Demonstrates the use of the Sampler module to load and play external audio files. It covers setting the filename, handling the 'onload' event to trigger playback at different rates (including reverse), and configuring loop properties. ```javascript rhodes = Sampler({ filename: 'http://yourserver.com/samples/rhodes.wav' }).connect() rhodes.onload = function() { rhodes.note(1) // Play at normal speed rhodes.note(2) // Play at double speed rhodes.note(-1) // Play in reverse rhodes.note(0.5) // Play at half speed } // Sampler properties rhodes.loops = true // Enable looping rhodes.start = 0 // Start position in samples rhodes.end = rhodes.data.length // End position ``` -------------------------------- ### Implement Feedback Loop with SSD Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Shows how to use the Single-Sample Delay (SSD) unit to create a feedback loop by modulating an oscillator's frequency with its own previous output. ```javascript ssd = SSD() sin = Sine({ frequency: Add( 440, Mul( ssd.out, 100 ) ) }).connect() // sample our sine oscillator ssd.listen( sin ) ``` -------------------------------- ### Initialize Flatdoc with File Fetcher Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/index.html This snippet demonstrates how to initialize Flatdoc to fetch documentation from a local file named 'docs.md'. Flatdoc is a static site generator for documentation. ```javascript Flatdoc.run({ fetcher: Flatdoc.file('docs.md') }) ``` -------------------------------- ### Follow UGen Initialization Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Initializes an envelope follower to track the amplitude of a target unit generator. ```APIDOC ## Follow UGen ### Description The Follow unit generator tracks the input signal and outputs its envelope, which can be used to modulate other parameters in the audio graph. ### Method Constructor / Initialization ### Endpoint Gibberish.Follow({ input: ugen, bufferSize: number }) ### Parameters #### Properties - **input** (ugen) - Required - The unit generator that will be tracked. - **bufferSize** (number) - Optional - Default: 8192. The length of the buffer over which averaging occurs. Longer buffers result in smoother signals, while shorter buffers respond more quickly. ### Request Example ```javascript tracker = Follow({ input: trackedUgen, bufferSize: 4096 }) ``` ### Response #### Success Response - **output** (signal) - Returns a signal representing the envelope of the input ugen. ``` -------------------------------- ### Gibberish: Single Sample Delay (SSD) for Feedback Loops Source: https://context7.com/gibber-cc/gibberish/llms.txt Illustrates the use of the Single Sample Delay (SSD) unit generator to create single-sample feedback loops, enabling advanced Digital Signal Processing (DSP) techniques. It shows how to use the .out property for feedback and .listen() to monitor the output. ```javascript ssd = SSD() // Use ssd.out for feedback sine = Sine({ frequency: Add(440, Mul(ssd.out, 100)) }).connect() // Listen to the output for feedback ssd.listen(sine) // Stereo SSD ssdStereo = SSD({ isStereo: true }) ``` -------------------------------- ### Synthesize Audio and Sequence Events with Gibberish Source: https://github.com/gibber-cc/gibberish/blob/v3/README.markdown Demonstrates creating a kick drum, sequencing its trigger events, and setting up a polyphonic synthesizer connected to a chorus effect. ```javascript kik = Kick().connect() seq = Sequencer.make( [.25,.5], [22050], kik, 'trigger' ).start() chr = Chorus().connect() syn = PolySynth({ maxVoices:4, attack:44, decay:22050, gain:.1 }) syn.connect( chr ).connect() syn.chord( [220,330,440,550] ) ``` -------------------------------- ### Audio Synthesis and Sequencing Source: https://github.com/gibber-cc/gibberish/blob/v3/README.markdown Demonstrates how to create audio objects and sequence them using the Gibberish API. ```APIDOC ## Create and Connect Synth ### Description Instantiates a synthesizer or oscillator and connects it to the master output. ### Method POST ### Endpoint /synth/create ### Request Body - **type** (string) - Required - The type of synth (e.g., 'Kick', 'PolySynth', 'Sine'). - **options** (object) - Optional - Configuration parameters for the synth. ### Request Example { "type": "PolySynth", "options": { "maxVoices": 4, "gain": 0.1 } } ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created synth instance. ## Sequence Trigger ### Description Schedules events for a specific synth method. ### Method POST ### Endpoint /sequencer/make ### Request Body - **values** (array) - Required - Values to sequence. - **durations** (array) - Required - Timing intervals. - **target** (object) - Required - The synth instance. - **method** (string) - Required - The method to trigger (e.g., 'trigger'). ### Request Example { "values": [0.25, 0.5], "durations": [22050], "target": "kik", "method": "trigger" } ``` -------------------------------- ### Hat Instrument Control Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Shows how to initialize the Hat instrument and modulate its decay and tuning properties to change the sound output. ```javascript hat = Gibberish.Hat().connect() hat.trigger( .5 ) hat.decay = .25 hat.trigger( .5 ) hat.tune = .75 hat.trigger( .5 ) hat.decay = .8 hat.tune = .25 hat.trigger( .5 ) ``` -------------------------------- ### Configure Complex Instrument with Sequencer Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Initializes the Complex instrument with specific pregain and decay values, then uses Sequencers to dynamically alter the pregain and trigger notes. This demonstrates the instrument's wavefolding capabilities and envelope control. ```javascript complex = Gibberish.instruments.Complex({ pregain:50, decay:44100, attack:44 }).connect() Gibberish.Sequencer({ target:complex, key:'pregain', values:[ 5,10,25,50 ], timings:[44100] }).start() Gibberish.Sequencer({ target:complex, key:'note', values:[ 2200 ], timings:[ 44100 ] }).start() ``` -------------------------------- ### Karplus-Strong Plucked String Model and Polyphony Source: https://context7.com/gibber-cc/gibberish/llms.txt Implements a physical model of a plucked string using the Karplus-Strong algorithm. The code shows how to initialize the string with parameters like decay and damping, trigger notes, and utilize a polyphonic version for chords. ```javascript pluck = Karplus({ decay: 4, // Decay time in seconds damping: 0.2, // String damping (0-1) glide: 1, // Portamento gain: 1 }).connect() pluck.note(440) pluck.note(550) // Polyphonic version polyPluck = PolyKarplus({ maxVoices: 4 }).connect() polyPluck.chord([330, 440, 550, 660]) ``` -------------------------------- ### Connect Unit Generators in Gibberish Source: https://context7.com/gibber-cc/gibberish/llms.txt Demonstrates how to connect unit generators (ugens) in Gibberish. Connections can be made to the master output or to other ugens like effects and filters. An optional gain parameter controls the signal level. Multiple destinations and bus routing are supported. ```javascript // Basic connection to master output syn = Synth().connect() // Connect to master with reduced gain syn2 = Synth().connect(Gibberish.output, 0.5) // Connect to effect and master output reverb = Freeverb({ roomSize: 0.9 }).connect() syn3 = Synth() .connect(reverb, 0.3) // Send 30% to reverb .connect() // Also connect dry signal to master // Multiple instruments to one effect via a bus effectBus = Bus().connect() reverb2 = Freeverb({ input: effectBus }).connect() Synth().connect(effectBus, 0.25) Synth().connect(effectBus, 0.25) FM().connect(effectBus, 0.25) ``` -------------------------------- ### Sequencer Control Source: https://context7.com/gibber-cc/gibberish/llms.txt Demonstrates sample-accurate sequencing of properties and methods, including dynamic value generation via functions. ```javascript syn = Synth({ attack: 44, decay: 22050 }).connect() seq = Sequencer({ target: syn, key: 'note', values: [440, 880, 1760], timings: [11025, 22050] }).start() seq2 = Sequencer.make([220, 330, 440, 550], [22050], syn, 'note').start() seq3 = Sequencer.make([1], [44100], snare, 'trigger').start(22050) seq4 = Sequencer({ target: syn, key: 'note', values: [() => 200 + Math.random() * 400], timings: [() => 5512 + Math.random() * 11025] }).start() seq5 = Sequencer({ target: hat, key: 'decay', values: [() => Math.random() > 0.25 ? 0.05 : 0.2], timings: [5512] }).start() seq.stop() ``` -------------------------------- ### Sequencer API Source: https://context7.com/gibber-cc/gibberish/llms.txt Demonstrates sample-accurate sequencing of method calls, property changes, and function execution using the Sequencer module. ```APIDOC ## Sequencer Sample-accurate sequencing of method calls, property changes, and function execution. ### Example Usage ```javascript syn = Synth({ attack: 44, decay: 22050 }).connect() // Basic sequencer seq = Sequencer({ target: syn, key: 'note', values: [440, 880, 1760], timings: [11025, 22050] // Alternates between timings }).start() // Shorthand factory method seq2 = Sequencer.make( [220, 330, 440, 550], // values [22050], // timings syn, // target 'note' // key ).start() // Delayed start (one beat delay) seq3 = Sequencer.make([1], [44100], snare, 'trigger').start(22050) // Dynamic values using functions seq4 = Sequencer({ target: syn, key: 'note', values: [() => 200 + Math.random() * 400], timings: [() => 5512 + Math.random() * 11025] }).start() // Sequencing property changes seq5 = Sequencer({ target: hat, key: 'decay', values: [() => Math.random() > 0.25 ? 0.05 : 0.2], timings: [5512] }).start() // Stop sequencer seq.stop() ``` ``` -------------------------------- ### Gibberish Core Methods Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Methods for managing the Gibberish audio engine lifecycle, including initialization, clearing, and namespace exporting. ```APIDOC ## gibberish.init ### Description Initializes the Gibberish audio session by creating an AudioContext and ScriptProcessor node. ### Parameters #### Request Body - **memorySize** (int) - Optional - Size of the memory block for ugens. Default: 44100 * 60 * 20. ## gibberish.clear ### Description Disconnects all ugens from the master bus and stops all running sequencers. ## gibberish.export ### Description Exports the Gibberish namespace to a target object. ### Parameters #### Request Body - **target** (object) - Required - The object to export the namespace to. - **shouldExportGenish** (boolean) - Optional - Whether to export genish.js unit generators. Default: false. ``` -------------------------------- ### Apply Filter24Moog to a Synth Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates how to instantiate a Filter24Moog effect, modulate its cutoff frequency using a sine oscillator, and connect it to a synthesizer. ```javascript syn = Gibberish.instruments.Synth({ attack:44, decay:44100 * 4 }) filter = Gibberish.filters.Filter24Moog({ input:syn, cutoff: Gibberish.binops.Add( .25, Gibberish.oscillators.Sine({ frequency:2, gain:.35 }) ), Q: .8, }).connect() syn.note( 220 ) ``` -------------------------------- ### Sampler API Source: https://context7.com/gibber-cc/gibberish/llms.txt The Sampler component loads external audio files and allows for variable playback speeds and looping. ```APIDOC ## Sampler ### Description Loads and plays external audio files at variable speeds. Negative rates play in reverse. ### Parameters #### Request Body - **filename** (string) - Required - URL of the audio file ### Request Example { "filename": "http://yourserver.com/samples/rhodes.wav" } ``` -------------------------------- ### Apply Filter24TB303 to a Synth Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md Demonstrates how to instantiate a Filter24TB303 effect with resonance and modulation, and connect it to a synthesizer. ```javascript syn = Gibberish.instruments.Synth({ attack:44, decay:44100 * 4 }) filter = Gibberish.filters.Filter24TB303({ input:syn, cutoff: Gibberish.binops.Add( .25, Gibberish.oscillators.Sine({ frequency:2, gain:.2 }) ), Q: .9, }).connect() syn.note( 220 ) ``` -------------------------------- ### Audio Filters Implementation Source: https://context7.com/gibber-cc/gibberish/llms.txt Demonstrates various filter types including Biquad, State Variable, Moog Ladder, and TB-303 Diode filters to shape the frequency response of a synthesizer signal. ```javascript syn = Synth({ attack: 44, decay: 44100 * 4 }) biquad = Filter12Biquad({ input: syn, cutoff: 0.5, Q: 0.5, mode: 0 }).connect() svf = Filter12SVF({ input: syn, cutoff: 0.3, Q: 0.7, mode: 0 }).connect() moog = Filter24Moog({ input: syn, cutoff: Add(0.25, Sine({ frequency: 2, gain: 0.35 })), Q: 0.8 }).connect() tb303 = Filter24TB303({ input: syn, cutoff: 0.3, Q: 0.9, saturation: 2 }).connect() syn.note(220) ``` -------------------------------- ### Initialize and Use Gibberish Delay Effect Source: https://github.com/gibber-cc/gibberish/blob/v3/docs/docs.md This snippet demonstrates how to initialize a Delay effect in Gibberish, connect it to a Synth instrument, and trigger a note. The Delay effect allows for time-based signal manipulation with adjustable delay time and feedback. ```javascript syn = Gibberish.instruments.Synth({ attack:44 }) delay = Gibberish.effects.Delay({ input:synth, delayTime: 5512, feedback: .9 }).connect() syn.note( 220 ) ``` -------------------------------- ### Gibberish: Analysis Envelope Follower for Modulation Source: https://context7.com/gibber-cc/gibberish/llms.txt Demonstrates the Analysis Envelope Follower (Follow) unit generator, which tracks the amplitude envelope of audio signals for modulation purposes. It shows how to connect an input signal and use the tracker's output to modulate other parameters. ```javascript trackedUgen = Karplus({ gain: 2 }).connect() Sequencer({ target: trackedUgen, key: 'note', values: [440, 880], timings: [22050] }).start() tracker = Follow({ input: trackedUgen, bufferSize: 8192 // Averaging buffer length }) // Use tracker output to modulate other parameters Sine({ frequency: Add(440, Mul(tracker, 220)), gain: 0.25 }).connect() ```