musdb developer on retainer: track.audio shape is (n_samples, 2) channels-last — developer extracts audio[:, 0] left channel only — 40% of tracks have right-panned vocals — separator trains on attenuated vocal targets — median vocal SDR 8.2 dB not 11.4 dB — 3 weeks — musdb developer on monthly retainer
musdb 0.4.0 • Python 3.9 • librosa 0.9.2; track.audio shape (n_samples, 2) channels-last; developer extracts track.targets['vocals'].audio[:, 0] (left channel); 40% of MUSDB18 tracks right-panned (left RMS 35–45% of stereo); • Northfield Musdb Ltd. (music source separation training; 20,000 stereo tracks/month; separator trains on under-energised vocal targets; museval SDR 8.2 dB not 11.4 dB; 3 weeks; fix: .mean(axis=1); 1.5h retainer engagement)
Northfield Musdb Ltd. built a music source separation model training system using the MUSDB18 dataset as the foundation corpus. Their pipeline loaded all 150 training tracks via musdb 0.4.0, extracted 4-second random chunks, converted the stereo mix and vocal stem to mono, and trained a Demucs-v2 architecture to predict isolated vocals from the full mixture. The separation model was intended for a commercial service that isolates vocal tracks from uploaded stereo recordings for 20,000 music producers and remix engineers per month. After 3 weeks of training (60 epochs on the full MUSDB18 training set), the model was evaluated against the MUSDB18 test set using museval. The median vocal SDR (Signal-to-Distortion Ratio) was 8.2 dB, compared to the 11.4 dB that the same architecture achieves when trained correctly. The developer had been systematically extracting the mix as mono_mix = track.audio.mean(axis=1) (correct) but the vocal target as mono_vocals = track.targets['vocals'].audio[:, 0] (left channel only), producing an energy mismatch between mix and target for tracks whose vocals were mixed off-centre.
musdb 0.4.0 returns all audio as numpy float32 arrays with shape (n_samples, 2): time is on axis 0, channels are on axis 1 (channels-last). track.audio[:, 0] returns the left channel and track.audio[:, 1] returns the right channel; track.audio.mean(axis=1) returns a mono average. This convention is consistent with soundfile.read() and librosa.load(mono=False). The developer used .mean(axis=1) for the mix but [:, 0] for the vocal stem, reasoning that “the left channel is a good approximation of the mono vocal.” In the MUSDB18 dataset, approximately 60% of tracks have lead vocals panned at or near centre (left/right RMS ratio between 0.85 and 1.15) — for these tracks, left-channel extraction is a reasonable approximation. The remaining 40% of tracks have vocals mixed with more energy in the right channel: left-channel RMS is 35–52% of the stereo vocal RMS, reflecting standard music production practice where lead vocals are occasionally panned 20–40% toward one side for stereo width. For these tracks, track.targets['vocals'].audio[:, 0] returns a vocal signal with less than half the energy that the full stereo stem carries. The mix track.audio.mean(axis=1) correctly captures the full energy of all instruments including the right-channel vocal energy; the vocal target the separator is trained to predict is a weakened version that underrepresents the actual vocal contribution to the mix. The model minimises MSE between its prediction and the left-channel-only target by learning to predict quieter vocals — a prediction that is acoustically wrong for centre-panned tracks and catastrophically wrong for right-panned tracks. The 3.2 dB SDR gap (8.2 dB vs 11.4 dB) is confirmed by per-track analysis: mean vocal SDR for the 60% centre-panned test tracks is 11.1 dB, comparable to the literature, while mean vocal SDR for the 40% right-panned test tracks is 5.1 dB, confirming systematic under-prediction of vocal energy in those tracks.
The annotated buggy and fixed musdb mono conversion pipeline, with channel consistency validation:
# Northfield Musdb Ltd. — musdb 0.4.0 mono channel conversion fix
# musdb 0.4.0; Python 3.9; librosa 0.9.2
# Music source separation training; 20,000 stereo tracks/month
#
# Problem: track.audio.mean(axis=1) for mix (correct)
# track.targets['vocals'].audio[:, 0] for stems (left channel only)
# 40% of MUSDB18 tracks have right-panned vocals (left RMS 35-45%)
# separator learns attenuated vocal targets → SDR 8.2 dB not 11.4 dB
# Fix: track.targets[stem].audio.mean(axis=1) for consistent mono conversion
import numpy as np
import musdb
SAMPLE_RATE = 44100
CHUNK_SECONDS = 4.0
CHUNK_SAMPLES = int(CHUNK_SECONDS * SAMPLE_RATE)
STEMS = ['vocals', 'drums', 'bass', 'other']
# ── BUGGY mono conversion ──────────────────────────────────────────────────────
def load_chunk_buggy(track, offset: int):
"""Load a 4-second chunk — BUGGY: left channel for stems, mean for mix."""
end = offset + CHUNK_SAMPLES
# Correct: mix uses channel average → full mix energy
mono_mix = track.audio[offset:end].mean(axis=1) # shape (CHUNK_SAMPLES,)
targets = {}
for stem in STEMS:
stem_audio = track.targets[stem].audio[offset:end]
# BUG: left channel only for all stems
# For centre-panned stems: approximately correct
# For right-panned vocals (40% of MUSDB18): only 35-45% of stem energy
targets[stem] = stem_audio[:, 0] # shape (CHUNK_SAMPLES,)
# NOTE: for right-panned tracks:
# mono_mix energy ≈ 100% of mix (correct)
# targets['vocals'] energy ≈ 35-45% of vocal stem (wrong)
# Separator trained to minimise MSE learns to predict quiet vocals
return mono_mix, targets
# ── FIXED mono conversion ───────────────────────────────────────────────────────
def audit_channel_balance(track) -> dict:
"""Check left/right RMS ratio for each stem — flag off-centre panning."""
ratios = {}
for stem in STEMS:
audio = track.targets[stem].audio # (n_samples, 2)
rms_left = np.sqrt((audio[:, 0] ** 2).mean())
rms_right = np.sqrt((audio[:, 1] ** 2).mean())
ratios[stem] = rms_left / (rms_right + 1e-9)
return ratios
def load_chunk_fixed(track, offset: int):
"""Load a 4-second chunk — FIXED: mean(axis=1) for mix AND stems."""
end = offset + CHUNK_SAMPLES
# FIX: channel average for mix
mono_mix = track.audio[offset:end].mean(axis=1) # shape (CHUNK_SAMPLES,)
targets = {}
for stem in STEMS:
stem_audio = track.targets[stem].audio[offset:end]
# FIX: channel average for all stems — consistent with mix
# Captures full stem energy regardless of panning
targets[stem] = stem_audio.mean(axis=1) # shape (CHUNK_SAMPLES,)
# Validate mix consistency: mix ≈ sum of all stems
stem_sum = sum(targets[s] for s in STEMS)
residual_rms = np.sqrt(((mono_mix - stem_sum) ** 2).mean())
if residual_rms > 0.05:
raise ValueError(
f"Mix-stem residual RMS {residual_rms:.4f} > 0.05 for track {track.name}. "
"Verify that track.audio.mean(axis=1) == sum(targets[s].mean(axis=1))."
)
return mono_mix, targets
def validate_dataset_channel_consistency(db):
"""Audit first 10 tracks for off-centre panning — log potential issues."""
for i, track in enumerate(db):
if i >= 10:
break
ratios = audit_channel_balance(track)
for stem, ratio in ratios.items():
if ratio < 0.70 or ratio > 1.43:
print(
f"Track {track.name}: {stem} L/R RMS ratio = {ratio:.2f} "
"(off-centre panning detected). "
"Use .mean(axis=1) for consistent mono conversion, not [:, 0]."
)
How left-channel-only stem extraction, asymmetric mono conversion, and absent panning audits combine to silently train a separator on attenuated vocals for 3 weeks — and the correct musdb pattern for stereo-to-mono source separation training
The root cause is an asymmetric mono conversion: the mix was correctly converted with .mean(axis=1) while stems used [:, 0]. For centre-panned tracks, both methods are approximately equivalent: left-channel energy and channel-average energy differ by less than 1 dB. For off-centre-panned tracks — which represent 40% of MUSDB18 — the difference is 6–9 dB for the affected stem. The separator is trained on (mix, stem) pairs where the mix faithfully represents the full acoustic scene and the stem underrepresents the target source for 40% of training examples. The MSE minimiser finds a solution that is quietly correct for centre-panned tracks and quietly wrong for right-panned tracks — producing lower overall SDR that is not immediately explained by any apparent training anomaly (loss decreases normally, validation SDR improves normally across epochs, just plateaus lower than expected). The SDR gap is only diagnosed when per-track evaluation is run with panning metadata: plotting SDR against the left/right RMS ratio of the vocal stem reveals a clear monotonic relationship — tracks with more right-panning produce lower SDR — that is the fingerprint of left-channel-only extraction. The fix is a one-line change to all stem extractions: .mean(axis=1) instead of [:, 0]. The model was retrained from scratch (60 epochs); at the same checkpoint, museval SDR improved from 8.2 to 11.3 dB overall, and from 5.1 to 10.8 dB on the previously underperforming right-panned subset. The mix consistency check — verifying that mono_mix ≈ sum(targets[s]) within 0.05 RMS — is an inexpensive test that catches not only this bug but also any other mix/stem loading inconsistency. The retainer engagement was 1.5h: 0.3h triage (per-track SDR logging; Pearson correlation between vocal SDR and left-to-right RMS ratio = 0.71; isolate to mono conversion); 0.4h root cause (.mean(axis=1) vs [:, 0]; energy mismatch for 40% of right-panned tracks; separator minimises MSE on under-energised targets); 0.4h fix (.mean(axis=1) for all stems; add channel balance audit; add mix consistency check; retrain from scratch); 0.4h validation (SDR 8.2 dB → 11.3 dB; panning correlation 0.71 → 0.08; 1.5h total). Hours logged to HourTab with per-session breakdown.
Related retainer posts
- nussl developer on retainer — nussl 1.1.9; Python 3.9; podcast source separation; 8,000 recordings/month;
audio_data[:, 0]= shape(2,)not(n_samples,); VAD receives 2-sample signal; Repet never triggered; fix:audio_data[0, :]— 1.5h - openl3 developer on retainer — openl3 0.4.2; Python 3.9; audio similarity engine; 50,000 clips/month;
soundfile.read()returns int16; embeddings cluster; cosine similarity 0.99; fix:dtype='float32'— 2.0h - kapre developer on retainer — kapre 0.3.7; Python 3.9; TF 2.8; music genre classification; 100,000 tracks/month;
load_model()raisesValueError; untrained fallback; 97% “Electronic”; fix:custom_objects=kapre.utils.get_custom_objects()— 1.5h
Track retainer hours without a client portal
HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.
See pricing →