> ## Documentation Index
> Fetch the complete documentation index at: https://songbird.studiocollective.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# songbird-plugins

# songbird-plugins

16 stock DSP plugins — Rust ports of the C++ originals. Every plugin implements the `Plugin` trait for a uniform interface across effects and instruments.

## Plugin Inventory

### Effects (10)

| Plugin           | Type Name            | Description                                                                                                           | Key Parameters                                                                                                                                                |
| ---------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **ChannelStrip** | `songbirdStrip`      | 9-stage channel strip (HPF → gate → EQ → transient shaper → compressor → saturation → stereo width → depth → limiter) | 28 params: gain, pan, HPF freq, gate threshold, 3-band EQ, comp ratio/threshold/attack/release, saturation drive, stereo width, depth amount, limiter ceiling |
| **Reverb**       | `songbirdReverb`     | Freeverb algorithm with pre-delay                                                                                     | room\_size, damping, wet, dry, width, predelay                                                                                                                |
| **Delay**        | `songbirdDelay`      | Stereo delay with ping-pong mode                                                                                      | delay\_time\_l, delay\_time\_r, feedback, wet, dry, ping\_pong, sync                                                                                          |
| **Chorus**       | `songbirdChorus`     | Stereo chorus with LFO modulation                                                                                     | rate, depth, mix, voices, spread                                                                                                                              |
| **Phaser**       | `songbirdPhaser`     | Multi-stage allpass phaser                                                                                            | rate, depth, feedback, stages, mix                                                                                                                            |
| **Flanger**      | `songbirdFlanger`    | Flanging via short modulated delay                                                                                    | rate, depth, feedback, mix                                                                                                                                    |
| **Compressor**   | `songbirdCompressor` | Dynamic range compressor                                                                                              | threshold, ratio, attack, release, knee, makeup\_gain                                                                                                         |
| **Distortion**   | `songbirdDistortion` | Multi-mode distortion (soft clip, hard clip, fuzz, bitcrush)                                                          | drive, mode, tone, mix                                                                                                                                        |
| **Doubler**      | `songbirdDoubler`    | Stereo doubling via micro-delays + detuning                                                                           | delay, detune, width, mix                                                                                                                                     |
| **ScriptFX**     | `songbirdScriptFX`   | User-scriptable DSP (JavaScript/Faust/WASM)                                                                           | script\_source, custom params                                                                                                                                 |

### Instruments (6)

| Plugin          | Type Name             | Description                                                                              | Key Parameters                                                                                   |
| --------------- | --------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| **Synth4Osc**   | `songbird4OSC`        | 4-oscillator subtractive synth                                                           | 4x (waveform, level, detune, octave), filter (cutoff, resonance, type), ADSR (amp + filter), LFO |
| **SynthStk**    | `songbirdSTK`         | Synthesis toolkit (6 STK algorithms: BlitSaw, BlitSquare, SineWave, Noise, BiQuad, ADSR) | algorithm, cutoff, resonance, adsr                                                               |
| **Synth303**    | `songbird303`         | Acid bass synth (diode ladder filter)                                                    | cutoff, resonance, env\_mod, decay, accent, waveform                                             |
| **Sampler**     | `songbirdSampler`     | Multi-sample playback with velocity layers                                               | root\_note, sample\_start, sample\_end, loop\_start, loop\_end, adsr                             |
| **DrumMachine** | `songbirdDrumMachine` | 16-pad drum machine with per-pad controls                                                | 16x (sample, volume, pan, pitch, decay)                                                          |
| **Metronome**   | `songbirdMetronome`   | Click track generator (accent on beat 1)                                                 | volume, accent\_volume, frequency, accent\_frequency                                             |

## Plugin Trait

All plugins implement this interface:

```rust theme={null}
pub trait Plugin: Send {
    fn type_name(&self) -> &str;           // Factory identifier (e.g., "songbirdReverb")
    fn name(&self) -> &str;                // Display name (e.g., "Reverb")
    fn initialize(&mut self, sample_rate: f64);
    fn reset(&mut self);                   // Clear all internal state (delays, filters, etc.)
    fn process(&mut self, buffer: &mut AudioBuffer, midi_events: &[MidiEvent]);
    fn params(&self) -> Vec<PluginParam>;  // Current parameter snapshot
    fn set_param(&mut self, name: &str, value: f64);
    fn save_state(&self) -> Vec<u8>;       // Binary state for recall
    fn load_state(&mut self, data: &[u8]);
    fn tail_seconds(&self) -> f64;         // Reverb tail, delay feedback, etc.
    fn latency_samples(&self) -> usize;    // Plugin latency for PDC
    fn accepts_midi(&self) -> bool;        // true for instruments
    fn produces_midi(&self) -> bool;       // true for MIDI effects
}
```

## Plugin Factory

```rust theme={null}
use songbird_plugins::{create_plugin, stock_plugin_types};

// Create by type name
let reverb = create_plugin("songbirdReverb").unwrap();

// List all stock plugin type names
for name in stock_plugin_types() {
    println!("{name}");
}
```

## MidiEvent

```rust theme={null}
pub enum MidiEvent {
    NoteOn { channel: u8, note: u8, velocity: f32 },
    NoteOff { channel: u8, note: u8 },
    CC { channel: u8, cc: u8, value: f32 },
    PitchBend { channel: u8, value: f32 },       // -1.0 to 1.0
    Aftertouch { channel: u8, pressure: f32 },
    PolyAftertouch { channel: u8, note: u8, pressure: f32 },
    ProgramChange { channel: u8, program: u8 },
}
```

## AudioBuffer

Thin wrapper over raw float pointers. Supports up to 8 channels with zero heap allocation:

```rust theme={null}
pub struct AudioBuffer {
    channels: [*mut f32; 8],
    num_channels: usize,
    num_samples: usize,
}
```

## Conventions

* **Parameter names** are `snake_case` strings (e.g., `"delay_time_l"`, `"filter_cutoff"`)
* **Parameter values** are normalized `f64` with `min`/`max`/`default` metadata in `PluginParam`
* **State serialization** uses `serde_json` internally (JSON bytes via `save_state()` / `load_state()`)
* **DSP is deterministic** — same input + same state = same output, enabling golden-output regression tests
* **All plugins are `Send`** — safe to move between threads for parallel graph processing

## Testing

```bash theme={null}
cargo test -p songbird-plugins  # Unit tests + factory tests
```

Factory tests verify:

1. All 16 plugins can be created from their type name
2. Unknown type names return `None`
3. State round-trip: create → modify param → save → create fresh → load → params match
