MCPcopy Index your code
hub / github.com/WeebLabs/DSPi

github.com/WeebLabs/DSPi @v1.1.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.4 ↗ · + Follow
1,173 symbols 3,027 edges 124 files 292 documented · 25% updated 1d agov1.1.5-beta3 · 2026-07-06★ 1,0307 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

DSPi Firmware

DSPi transforms a Raspberry Pi Pico or other RP2040-based board into a very competent and inexpensive little digital audio processor. It acts as a USB sound card with an onboard DSP engine, allowing you to make use of essential tools like room correction, active crossovers, parametric EQ, time alignment, loudness compensation, and headphone crossfeed.

It is my hope that the RP2040 and RP2350 will garner a reputation as the "swiss army knife of audio for less than a cup of coffee".


Table of Contents


Key Capabilities

  • USB Audio Interface: Plug-and-play under macOS, Windows, Linux, and iOS. Supports 16-bit and 24-bit PCM input at 44.1, 48, and 96 kHz.
  • 24-bit S/PDIF or I2S Outputs: Up to four independent stereo output slots (8 channels on RP2350, 4 channels on RP2040). Each slot can be switched at runtime between S/PDIF and I2S, enabling direct connection to any standard DAC. I2S slots share a common BCK/LRCLK and can optionally produce a 128×/256× master clock.
  • Per-Channel Preamp: Independent gain control for each USB input channel (L/R), applied as PASS 1 of the DSP pipeline before any other processing.
  • Matrix Mixer: Route either or both USB input channels to any output with independent gain and phase invert per crosspoint. 2x9 on RP2350, 2x5 on RP2040.
  • Parametric Equalization: Up to 10 PEQ bands per channel with 6 filter types. 110 total filter bands on RP2350, 70 on RP2040. RP2350 uses a hybrid SVF/biquad architecture for superior low-frequency accuracy.
  • Volume Leveller: RMS-based, stereo-linked, soft-knee upward compressor that lifts quieter content toward a target level without ever amplifying loud passages. Optional 10 ms lookahead, configurable speed and max-gain ceiling, with a -6 dBFS gain-reduction safety limiter.
  • Loudness Compensation: Volume-dependent EQ based on the ISO 226:2003 equal-loudness contour standard. Automatically boosts bass and treble at low listening levels to maintain perceived tonal balance.
  • Headphone Crossfeed: BS2B-based crossfeed with interaural time delay (ITD) reduces unnatural stereo separation for headphone listening. Three classic presets plus fully custom parameters.
  • Master Volume: Device-side output ceiling (-128 to 0 dB, with a true-mute sentinel) applied at the very end of the signal chain, independent of USB host volume and DSP processing. Two persistence modes: stored independently of presets (default — survives reboots, unaffected by preset switching) or saved/restored as part of each preset.
  • Per-Output Gain & Mute: Independent gain and mute controls for each output channel.
  • Time Alignment: Per-output delay (up to 85ms) for speaker/subwoofer alignment with automatic latency compensation between S/PDIF/I2S and PDM output paths.
  • Subwoofer Output: Dedicated mono PDM output channel with a high-performance 2nd-order delta-sigma modulator, enabling direct subwoofer output without the need for a second DAC.
  • Dual-Core DSP: EQ processing is split across both cores on both platforms for maximum throughput when multiple outputs are active.
  • Configurable Output Pins: All output GPIO pins (including I2S BCK/MCK) can be reassigned at runtime to suit custom PCB layouts, no reflashing required.
  • 10-Slot Preset System: Save, load, and manage up to 10 complete DSP configurations with user-defined names. Includes per-channel naming, configurable startup slot, and bulk parameter transfer for fast state synchronization.
  • Diagnostics: Per-channel peak/clip metering, USB PHY error counters (CRC, bit-stuff, timeout, overflow, sequence), buffer fill statistics, S/PDIF DMA starvation counters per output slot, and CPU load reporting per core.
  • Firmware Update via USB: A vendor command reboots the device into the UF2 bootloader, allowing the host app to push new firmware without a physical BOOTSEL press.

Platform Support

Feature RP2040 (Pico) RP2350 (Pico 2)
System Clock 307.2 MHz (overclock) 307.2 MHz
Core Voltage 1.15 V 1.15 V
Sample Rates 44.1 / 48 / 96 kHz 44.1 / 48 / 96 kHz
Audio Processing Q28 Fixed-Point Single-Precision Float
EQ Bands 10 per channel (70 total) 10 per channel (110 total)
Total Channels 7 (2 master + 4 S/PDIF·I2S + 1 PDM) 11 (2 master + 8 S/PDIF·I2S + 1 PDM)
Output Slots 2 stereo (each S/PDIF or I2S) 4 stereo (each S/PDIF or I2S)
Output Bit Depth 24-bit 24-bit
PDM Output 1 (subwoofer) 1 (subwoofer)
Max Delay 85ms per output 85ms per output
Math Engine Hand-optimized ARM Assembly Hardware FPU (hybrid SVF/biquad EQ)
Dual-Core EQ Yes (Core 1 processes outputs 3-4) Yes (Core 1 processes outputs 3-8)
User Presets 10 slots 10 slots
Status Production Production

Both platforms are fully tested and production-ready. The RP2040 reaches 307.2 MHz with a slight voltage bump; the RP2350 hits the same frequency at the same voltage. Clock is fixed (no rate-dependent switching), and PIO dividers are integer at every supported sample rate. The RP2350 offers significantly more processing headroom thanks to its hardware floating-point unit, enabling more output channels and a hybrid SVF/biquad filter architecture for improved low-frequency accuracy.


Audio Signal Chain

DSPi processes audio in a linear, low-latency pipeline:

RP2350 (11 channels, 9 outputs):

USB Input (16/24-bit PCM Stereo, 44.1 / 48 / 96 kHz)
    |
PASS 1: Per-Channel Preamp (independent L/R gain) + USB Volume
    |
PASS 2: Master EQ (10 bands per channel, Left/Right)
    |
PASS 2.5: Volume Leveller (RMS upward compression, optional)
    |
PASS 3: Headphone Crossfeed (BS2B + ITD, optional) + Master Peak Metering
    |
        Loudness Compensation (volume-dependent EQ, optional)
    |
PASS 4: Matrix Mixer (2 inputs x 9 outputs, per-crosspoint gain & phase)
    |
PASS 5: Per-Output EQ -> Gain/Mute -> Delay -> Output Gain × Master Volume
    |
    +-- Out 1-2 --> S/PDIF or I2S slot 0 (data: GPIO 6 default)
    +-- Out 3-4 --> S/PDIF or I2S slot 1 (data: GPIO 7 default)
    +-- Out 5-6 --> S/PDIF or I2S slot 2 (data: GPIO 8 default)
    +-- Out 7-8 --> S/PDIF or I2S slot 3 (data: GPIO 9 default)
    +-- Out 9   --> PDM Sub               (data: GPIO 10 default)
                  (I2S BCK/LRCLK shared on GPIO 14/15 default; optional MCK on GPIO 13 default)

RP2040 (7 channels, 5 outputs):

USB Input (16/24-bit PCM Stereo, 44.1 / 48 / 96 kHz)
    |
PASS 1: Per-Channel Preamp + USB Volume
    |
PASS 2: Master EQ (10 bands per channel, Left/Right)
    |
PASS 2.5: Volume Leveller (RMS upward compression, optional)
    |
PASS 3: Headphone Crossfeed (BS2B + ITD, optional) + Master Peak Metering
    |
        Loudness Compensation (volume-dependent EQ, optional)
    |
PASS 4: Matrix Mixer (2 inputs x 5 outputs, per-crosspoint gain & phase)
    |
PASS 5: Per-Output EQ -> Gain/Mute -> Delay -> Output Gain × Master Volume
    |
    +-- Out 1-2 --> S/PDIF or I2S slot 0 (data: GPIO 6 default)
    +-- Out 3-4 --> S/PDIF or I2S slot 1 (data: GPIO 7 default)
    +-- Out 5   --> PDM Sub               (data: GPIO 10 default)
                  (I2S BCK/LRCLK shared on GPIO 14/15 default; optional MCK on GPIO 13 default)

Signal Chain Details

  1. Input (USB): 16-bit or 24-bit PCM stereo audio at 44.1, 48, or 96 kHz. Bit depth is selected via USB alt setting; sample rate via the USB Audio Class rate-set request.
  2. Per-Channel Preamp (PASS 1): Independent gain control for the USB Left and Right input channels in dB. Applied at the very start of the DSP chain so its setting affects all downstream processing.
  3. Master EQ (PASS 2): Up to 10 bands of parametric EQ per channel (Left/Right). Supports peaking, low shelf, high shelf, low pass, and high pass filter types.
  4. Volume Leveller (PASS 2.5): Optional feedforward, stereo-linked, single-band RMS compressor with soft-knee upward compression — quieter content is boosted toward a target level while content above the threshold passes through untouched. Configurable speed, max-gain ceiling, and noise gate. Optional 10 ms lookahead. A -6 dBFS gain-reduction safety limiter prevents output overshoots.
  5. Headphone Crossfeed (PASS 3): Optional BS2B crossfeed that mixes a filtered, delayed portion of each channel into the opposite channel. Uses a complementary filter design with interaural time delay (ITD) via an all-pass filter. Three presets (Default, Chu Moy, Jan Meier) plus custom frequency and feed level. ITD can be independently toggled. Master peak metering taps into this stage.
  6. Loudness Compensation: Optional ISO 226:2003 equal-loudness EQ that adapts to the current volume level. At low volumes, bass and treble are boosted to compensate for the ear's reduced sensitivity. Configurable reference SPL and intensity. Driven by the USB host volume position so it remains correct regardless of master-volume attenuation downstream.
  7. Matrix Mixer (PASS 4): Routes the two USB input channels (Left/Right) to all output channels. Each crosspoint has independent enable, gain (-inf to +12 dB), and phase invert. Outputs can be individually enabled/disabled to save CPU. RP2350 has a 2x9 matrix (9 outputs), RP2040 has a 2x5 matrix (5 outputs).
  8. Output EQ (PASS 5): Independent 10-band EQ per output channel on both platforms. Ideal for crossover filters and per-driver correction. On RP2350, filters below Fs/7.5 use SVF topology for superior low-frequency accuracy; higher frequencies use traditional biquad.
  9. Per-Output Gain & Mute: Independent gain (-inf to +12 dB) and mute for each output channel.
  10. Time Alignment: Per-output delay for speaker alignment, up to 85 ms (4096 samples at 48 kHz). Automatic latency compensation between S/PDIF/I2S and PDM output paths.
  11. Master Volume: Device-side output ceiling, -128 to 0 dB with a true-mute sentinel at -128. Folded into the per-output multiplier at PASS 5 so it's effectively free CPU-wise. Independent of the USB host volume — the two multiply together. Does not affect loudness-compensation behavior.
  12. Outputs: Each numbered slot is configurable as either 24-bit S/PDIF or 24-bit I2S (left-justified, MSB-first). I2S slots share a common BCK/LRCLK clock pair (LRCLK is always BCK + 1 due to a PIO side-set constraint). An optional master clock (MCK) at 128× or 256× Fs can be routed to a separate GPIO. PDM subwoofer is always on its own dedicated output and pin.

Hardware Setup

Flashing the Firmware

  1. Download the latest DSPi.uf2 release for your board.
  2. Hold the BOOTSEL button on your Pico while plugging it into your computer.
  3. A drive named RPI-RP2 will appear.
  4. Drag and drop the .uf2 file onto this drive.
  5. The Pico will reboot and appear as a "Weeb Labs DSPi" audio device.
  6. Download and launch the DSPi Console application to control the DSPi.

Wiring Guide

RP2350 (Pico 2) — up to 8 output pins:

Function Pin Connection
Output Slot 0 (Out 1-2) GPIO 6 (default) S/PDIF or I2S data for main L/R or multi-way pair 1
Output Slot 1 (Out 3-4) GPIO 7 (default) S/PDIF or I2S data for multi-way pair 2
Output Slot 2 (Out 5-6) GPIO 8 (default) S/PDIF or I2S data for multi-way pair 3
Output Slot 3 (Out 7-8) GPIO 9 (default) S/PDIF or I2S data for multi-way pair 4
Subwoofer Out (PDM, Out 9) GPIO 10 (default) Active subwoofer or PDM-to-analog filter
I2S BCK (shared, I2S only) GPIO 14 (default) Bit clock for any slot configured as I2S
I2S LRCLK (I2S only) GPIO 15 (BCK + 1, fixed) Word/frame clock; always BCK + 1
I2S MCK (optional) GPIO 13 (default) 128× or 256× Fs master clock when MCK is enabled
USB Micro-USB Host device (PC/Mac/Mobile Device)

RP2040 (Pico) — up to 6 output pins:

Function Pin Connection
Output Slot 0 (Out 1-2) GPIO 6 (default) S/PDIF or I2S data for main L/R or stereo pair 1
Output Slot 1 (Out 3-4) GPIO 7 (default) S/PDIF or I2S data for stereo pair 2
Subwoofer Out (PDM, Out 5) GPIO 10 (default) Active subwoofer or PDM-to-analog filter
I2S BCK (shared, I2S only) GPIO 14 (default) Bit clock for any slot configured as I2S
I2S LRCLK (I2S only) GPIO 15 (BCK + 1, fixed) Word/frame clock; always BCK + 1
I2S MCK (optional) GPIO 13 (default) 128× or 256× Fs master clock when MCK is enabled
USB Micro-USB Host device (PC/Mac/Mobile Device)

Notes: S/PDIF output requires either a Toshiba TX179 optical transmitter or a simple resistor divider. I2S output

Core symbols most depended-on inside this repo

get_u8
called by 164
tools/dspi_test/device.py
writedata
called by 144
firmware/pico-extras/src/rp2_common/pico_scanvideo_dbi/tft_driver.c
eq
called by 132
tools/dspi_test/framework.py
get
called by 105
tools/dspi_test/device.py
vendor_send_response
called by 72
firmware/DSPi/vendor_commands.c
set_u8
called by 61
tools/dspi_test/device.py
get_f32
called by 58
tools/dspi_test/device.py
set_f32
called by 58
tools/dspi_test/device.py

Shape

Function 851
Class 201
Method 63
Enum 36
Route 22

Languages

C56%
C++23%
Python21%

Modules by API surface

firmware/pico-extras/src/rp2_common/usb_device/usb_device.c84 symbols
firmware/pico-extras/src/rp2_common/usb_device_msc/usb_device_msc.c55 symbols
firmware/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c45 symbols
firmware/pico-extras/src/common/pico_audio/include/pico/sample_conversion.h42 symbols
firmware/DSPi/flash_storage.c39 symbols
firmware/pico-extras/src/rp2_common/pico_spdif_rx/spdif_rx.c38 symbols
firmware/pico-extras/src/rp2_common/pico_sd_card/sd_card.c38 symbols
firmware/pico-extras/src/rp2_common/pico_scanvideo_dbi/video_dbi.c35 symbols
firmware/DSPi/usb_audio.c35 symbols
tools/dspi_test/tests/outputs.py29 symbols
tools/dspi_test/framework.py27 symbols
tools/dspi_test/device.py26 symbols

For agents

$ claude mcp add DSPi \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact