Published by FR Studios

SP-404MKII Streamer & Sample Crate

Building a native Linux PipeWire audio bridge and hardware-aware sample workstation with Rust and egui.

If you produce music on Linux and stream your workflow to friends or collaborators on Discord, Vesktop, or OBS, you have inevitably collided with the Linux screen-share audio barrier:

On Linux, Discord and Vesktop capture audio exclusively from application playback streams during screen shares. They completely ignore USB audio interfaces and hardware inputs.

If you route your hardware sampler’s USB output into your microphone channel, Discord’s default voice processing mangles your mix: aggressive noise suppression cuts out reverb tails, echo cancellation destroys transients, and stereo panning is flattened into muddy mono.

To fix this once and for all, I built SP-404MKII Streamer: a high-performance, lightweight Linux audio bridge and hardware-aware sample workstation engineered in Rust using egui and native PipeWire C FFI.


The Linux Audio Problem & PipeWire Virtual Node Bridge

Under PipeWire, modern Linux distributions (such as Arch, Fedora, and Ubuntu 24.04+) manage audio streams as node graphs. When an application captures desktop screen share audio, it looks for nodes with the media.class = "Stream/Output/Audio" property.

Traditional workarounds required manually launching complex GUI patchbays (like Helvum or qpwgraph) to build temporary loopback null-sinks on every boot.

SP-404MKII Streamer eliminates manual patching by binding directly to the PipeWire API via Rust FFI:

  ┌──────────────────────────────────────────────────────────────┐
  │                 Roland SP-404MKII (USB Audio)                │
  │                  48 kHz / 24-bit Stereo Line                 │
  └──────────────────────────────┬───────────────────────────────┘
                                 │
                     PipeWire Capture Node (FFI)
                                 │
                                 ▼
  ┌──────────────────────────────────────────────────────────────┐
  │              SP-404MKII Streamer (Rust Engine)               │
  │                                                              │
  │  • Real-time 32-segment stereo LED peak metering             │
  │  • Low-latency ring buffer (~5.3 ms buffer allocation)       │
  │  • Automatic jitter compensation & USB hotplug reconnection  │
  └──────────────┬───────────────────────────────┬───────────────┘
                 │                               │
       Monitor Playback Stream         Virtual Application Node
                 │                      (Screen Share Target)
                 ▼                               ▼
  ┌──────────────────────────────┐ ┌──────────────────────────────┐
  │ Headphones / Studio Monitors │ │ Discord / Vesktop / OBS      │
  │ (With 0 dB Unity Gain & Mute)│ │ (Crystal-clear 48 kHz Stereo)│
  └──────────────────────────────┘ └──────────────────────────────┘
  1. Virtual Application Stream: The app registers itself as an active audio-producing application window, allowing Discord or Vesktop to capture pristine 48 kHz stereo sampler audio with zero compression or gating.
  2. Zero-Latency Monitoring Deck: Route audio to your local headphones, studio monitors, or external DAC. Includes a 1-click Mute button to silence local computer playback when monitoring zero-latency audio directly from the SP-404MKII headphone jack.
  3. Hardware Hotplug: Automatically reconnects and restores audio routing whenever the sampler is plugged in or power-cycled over USB.

Hardware-Aware Sample Crate & SD Card Deck

Beyond streaming, prepping sample kits for the SP-404MKII is notoriously tedious. If a sample isn’t formatted to Roland’s exact hardware specifications, the device throws a frustrating “File Not Supported” error on import.

The integrated Sample Crate automates the entire ingestion and conforming pipeline:

  Raw Download / Sample Pack (44.1kHz, 96kHz, 24-bit, MP3, FLAC, AIFF)
                                 │
                                 ▼
               [Hardware Conforming Engine (Rust)]
                                 │
         ├── 48,000 Hz Resampling
         ├── 16-bit Linear PCM WAV Conversion
         ├── Polyphony Voice Preservation (Mono Stays 1-Channel Mono)
         └── FAT32 & OLED Display Sanitization (Max 16 Chars)
                                 │
                                 ▼
         [Safe SD Card Mount & sync_all() Kernel Flush]
                                 │
                                 ▼
             Ready-to-Play Roland SP-404MKII SD Card

1. The Conforming Engine (Saving Polyphony)

  • Automatic Resampling: Transcodes any format (MP3, FLAC, 24/32-bit floating point WAV) to 48,000 Hz 16-bit linear PCM.
  • Preserving Mono Polyphony: The SP-404MKII has a maximum polyphony of 32 voices. When stereo files are loaded, each consumes 2 voices. The conforming engine automatically detects single-channel mono sources and exports them as pure 1-channel mono—saving precious hardware voices for drum breaks and polyphonic chops.

2. FAT32 & OLED Display Sanitization

The Roland OLED screen truncates long filenames and chokes on special characters. The exporter automatically sanitizes filenames against illegal FAT32 characters, removes extraneous spaces, and conforms names to a clean 16-character format for instant legibility on hardware screens.

3. Safe SD Ejection via udisks2

Pulling an SD card before Linux kernel write caches flush can corrupt your entire sample library. The app discovers SD cards via DBus/udisks2, checks physical hardware write-lock switches, computes remaining disk capacity, executes an explicit sync_all() kernel cache flush, and safely unmounts the card with a single click.


Why Rust and egui?

When streaming live beats or playing DJ sets, audio stability is paramount. Electron-based or web-wrapper desktop tools consume hundreds of megabytes of RAM and spike CPU usage during UI renders.

By leveraging Rust and egui (immediate-mode GUI):

  • Tiny Footprint: Binary size is compact and memory usage typically stays under 25 MB.
  • Throttled Repaint: The UI automatically drops to single-digit FPS when idle, ramping up to 60 FPS only when rendering animated VU meters or interactive waveform scrubbing.
  • Direct C FFI: Interfacing directly with libpipewire provides rock-solid audio thread scheduling without GC pauses.

Summary

The SP-404MKII Streamer bridges the gap between hardware samplers and modern Linux collaborative environments. By combining native PipeWire routing with automated SD card sample preparation, beatmakers can focus entirely on creating music.

View SP-404MKII Streamer on GitHub →