Inspiration

The best moment in a DJ set is the one you don't notice: the point where one song slides into the next and the whole room keeps moving. I wanted to see whether I could build that moment in code.

What it does

StemSlice takes songs apart and puts them back together as DJ-style transitions.

  • It separates a track into stems (vocals, drums, bass, and everything else) using Demucs.
  • It blends songs with tempo-matched transitions, handling each stem on its own.

How I built it

  • Python and Demucs for stem separation and audio processing.
  • Exact-slice loading. Instead of loading a whole 3 to 4 minute song for a transition, the code calculates how much audio it needs from the tempo and the number of bars, and loads only that slice from disk. That cut memory use and processing time a lot.
  • Disk caching. Time-stretching audio to match tempos is expensive, so each processed result is saved with a filename that describes it (stem, duration, stretch rate). If the same piece is requested again, the code finds the file and loads it instantly. I used files, not memory, so the work survives between runs.

Challenges I ran into

My first versions were slow, because they reloaded and reprocessed far more audio than any transition needed. The hard part was working out exactly which data each transition required and what was safe to cache.

What I learned

Performance problems are usually data problems: load less, recompute less. A good cache key, such as a filename that fully describes the result, makes the rest of the code much simpler.

Built With

Share this project:

Updates