DEV Community

Cover image for Why I Extracted Rockbox's DSP Pipeline into a Reusable Rust Library
Tsiry Sandratraina
Tsiry Sandratraina

Posted on

Why I Extracted Rockbox's DSP Pipeline into a Reusable Rust Library

Every music player eventually reaches the same point.

Playing audio is the easy part. The difficult part is everything that comes after decoding: equalizers, bass and treble adjustment, ReplayGain, dynamic range compression, channel mixing, and all the little details that make music sound the way users expect.

Many projects end up implementing these features from scratch. I was heading down the same path while building two of my own applications: Fin, a terminal client for Jellyfin and Subsonic servers, and tunein-cli, a terminal internet radio player.

Both needed exactly the same audio processing pipeline.

Copying DSP code between projects didn't feel right, and maintaining two implementations would only become more painful over time. I started looking for a better solution.

Why Rockbox?

If you've been around portable audio players, you've probably heard of Rockbox.

Rockbox is an open-source firmware that has powered countless portable music players over the last two decades. One of its strongest components is its DSP pipeline. It has been refined over many years and provides features such as equalization, ReplayGain, bass and treble controls, dynamic compression, and more.

Instead of designing another DSP engine from scratch, I kept asking myself a simple question:

Why not reuse something that has already been tested by thousands of users for years?

That decision eventually became rockbox-dsp, a standalone Rust library that exposes Rockbox's audio processing pipeline in a form that any Rust application can use.

The Goal

I didn't want another media player.

I wanted a reusable building block.

The library doesn't know anything about MP3, FLAC, streaming services, or user interfaces. It simply receives decoded PCM audio, applies the configured DSP effects, and returns processed PCM samples.

That separation makes it useful in many different contexts.

A terminal music player can use it.

A desktop player can use it.

An internet radio client can use it.

A command-line audio processing tool can use it.

As long as your application can decode audio into PCM samples, it can benefit from the same DSP pipeline.

Features

The library currently provides the core audio processing available in Rockbox, including:

  • Multi-band equalizer
  • Bass and treble adjustment
  • ReplayGain support
  • Dynamic compressor
  • Channel mixing
  • Stereo width controls
  • Crossfeed
  • Additional PCM processing utilities

Because the processing happens after decoding, the source format doesn't matter. Whether the audio came from MP3, FLAC, AAC, Opus, or a network stream, the DSP pipeline works exactly the same way.

Why a Library Instead of Copying Code?

Extracting the DSP into its own crate solved several problems at once.

First, both of my applications now share exactly the same implementation. Bug fixes and improvements automatically benefit every project using the library.

Second, the code became much easier to test in isolation. Instead of debugging DSP behavior inside an application, I can validate the processing independently.

Finally, other Rust developers can reuse the same pipeline without copying pieces of my projects.

That's the biggest advantage of reusable libraries: improvements made by one project can benefit many others.

Real-World Usage

The library already powers several of my projects.

Fin uses it to provide audio enhancements while streaming from Jellyfin and Subsonic servers.

tunein-cli uses the same pipeline for internet radio playback.

More recently, I built a standalone terminal Equalizer that reads raw PCM audio from standard input, applies DSP processing, , and writes the processed PCM directly to the sound card.

That means it can be inserted into Unix audio pipelines alongside tools like ffmpeg or any application capable of producing raw PCM.

Seeing the same DSP engine reused across completely different applications confirmed that extracting it into a standalone crate was the right decision.

Lessons Learned

One of the biggest lessons from this project wasn't about DSP at all.

It's easy to build features directly into an application because that's the fastest path to shipping. But once two projects start sharing the same code, it's usually worth stepping back and asking whether that code should become its own library.

Open source grows stronger when useful components become reusable instead of remaining hidden inside larger applications.

I think there are probably many mature open-source projects with excellent subsystems waiting to be extracted and modernized in the same way.

Looking Ahead

The goal for rockbox-dsp isn't to replace existing audio frameworks.

It's to make a proven DSP pipeline easy to embed in Rust applications.

If you're building a music player, a streaming application, a radio client, or any software that processes PCM audio, I'd love to hear how you're using it. Feedback, bug reports, and contributions are always welcome.

Sometimes the best engineering decision isn't inventing something new.

Sometimes it's recognizing that an excellent solution already exists, and making it easier for others to use.

Top comments (0)