Source Separation

Open-Unmix HQ splits a stereo music track into four independent stems — vocals, drums, bass, and other. Four independent BiLSTM models (one per stem) produce magnitude masks over the mixture STFT; an optional Wiener post-filter reconciles them. Runs on Apple Silicon via MLX.

Two engines are available: Open-Unmix HQ (lightweight, the default) and HTDemucs (Demucs v4) — a higher-quality Hybrid Transformer model selected with --engine htdemucs. Both run on Apple Silicon via MLX and output the same four stems at 44.1 kHz.

What it is

Architecture

Four independent stems, each a copy of the same network:

StageShape / operation
STFT4096-point FFT, 1024-hop, periodic Hann window, reflect-pad. 2049 frequency bins per frame.
Input normalizeCrop to 1487 bins (≈16 kHz), apply learned per-bin mean + scale from training.
EncoderLinear 2974 → 512 + BatchNorm + tanh. Input is 2 channels × 1487 bins.
BiLSTM3 layers, 256 hidden per direction (512 effective). Captures temporal context across frames.
DecoderSkip-concat of encoder and LSTM outputs (1024) → Linear 1024 → 512 + BN + ReLU → Linear 512 → 4098.
Output denorm + maskElement-wise multiply with mixture magnitude; phase from mixture; iSTFT overlap-add.
Wiener (optional)Power-ratio masks across all 4 stem estimates. Refines phase so stems sum to mixture.

Model

ComponentValue
Parameters / stem8.9M
Parameters total (4 stems)~35.6M
Sample rate44.1 kHz stereo
Chunk latencyOffline (full-track STFT)
Weightsaufklarer/OpenUnmix-HQ-MLX (safetensors, ~136 MB)
Upstreamsigsep/open-unmix-pytorch (Stöter et al., JOSS 2019)

HTDemucs (Demucs v4)

For higher separation quality — especially on bass and drums — the package also ships HTDemucs, Meta's Hybrid Transformer Demucs. It merges a spectrogram branch and a waveform branch through a cross-domain transformer; the shipped htdemucs_ft variant is a bag of four fine-tuned sub-models, one per stem. Weights download from HuggingFace on first use. On a directional MUSDB-sample benchmark (museval / BSSEval v4) it averages +3.01 dB SDR over UMX-HQ, with the biggest gains on bass (+5.75 dB).

ComponentValue
Parameters168M (4 × 42M fine-tuned sub-models)
Sample rate44.1 kHz stereo
Windowing7.8 s segments, 25% overlap, triangular cross-fade
Weightsaufklarer/HTDemucs-FT-MLX (fp16, ~320 MB)
Upstreamfacebookresearch/demucs (Rouard et al., ICASSP 2023)

Quick start — Swift

import SourceSeparation
import AudioCommon

let separator = try await SourceSeparator.fromPretrained()

let stereo = try AudioFileLoader.loadStereo(
    url: URL(fileURLWithPath: "song.wav"),
    targetSampleRate: 44100
)

let stems = separator.separate(audio: stereo, sampleRate: 44100)
// stems[.vocals], stems[.drums], stems[.bass], stems[.other]
// Each is [[Float]] — left channel, right channel.

try WAVWriter.writeStereo(
    left: stems[.vocals]![0],
    right: stems[.vocals]![1],
    sampleRate: 44100,
    to: URL(fileURLWithPath: "vocals.wav")
)

Pass wiener: true (default) for best quality. Pass targets: [.vocals] to extract only a subset of stems and skip the other models.

CLI

speech separate song.wav                              # all 4 stems into song_stems/ (Open-Unmix)
speech separate song.wav --engine htdemucs            # Demucs v4 — higher quality
speech separate song.wav --engine htdemucs --htdemucs-precision int8  # smaller int8 bundle
speech separate song.wav --stems vocals               # vocals only
speech separate song.wav --stems vocals,drums         # subset
speech separate song.wav --output-dir /tmp/stems/     # custom output dir
speech separate song.wav --verbose                    # show timing

When to use

Open-Unmix fits when…

…you need a lightweight, offline source-separation pass inside an app or pipeline on Apple Silicon. 8.9M params per stem keeps download and memory modest. Magnitude-masking plus Wiener gives good stems on most pop/rock content. For state-of-the-art vocal isolation on studio material, switch to the bundled HTDemucs (Demucs v4) engine via --engine htdemucs; Open-Unmix remains the lightweight, ship-in-your-app end of the tradeoff.