From 0e5918a9bfe518549b3e42adfe42d1298de798d3 Mon Sep 17 00:00:00 2001 From: byrongamatos Date: Mon, 13 Jul 2026 15:09:04 +0200 Subject: [PATCH 1/2] fix: read the full mix from the reserved `full` stem, not `original_audio` (feedback#933) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pristine mixdown we play at unity used to arrive on song_info as `original_audio_url` — named after a manifest key core invented and the feedpak spec never had. The mixdown is a stem: feedpak 1.15.0 RESERVES the id `full` for it, and core now surfaces it as `full_mix_url` / `has_full_mix`. Core still lifts it OUT of `info.stems` before sending, which is what keeps this plugin correct: `full` already contains every instrument, so if it ever appeared among the tracks we sum, unity playback would double the whole song and muting "guitar" would leave guitar audible inside the mix. Reads the new fields, falling back to the deprecated aliases so the plugin still works against a core that predates the rename (a user can have a newer bundled plugin than server). The fallback goes when the aliases do (feedback#945). --- CHANGELOG.md | 12 ++++++++++++ src/main.js | 35 +++++++++++++++++++++++------------ src/streaming.js | 4 ++-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dcfbec..5921dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,18 @@ All notable changes to the Stems Toggle plugin are documented here. ### Changed +- **The full mix is a stem** (feedback#933). The pristine mixdown we play while + every fader sits at unity now arrives on `song_info` as `full_mix_url` / + `has_full_mix`. It used to arrive as `original_audio_url` — named after a + manifest key core invented and the feedpak spec never had. The mixdown is a + stem: feedpak 1.15.0 RESERVES the id `full` for it, and core reads it from + there. Core still lifts it OUT of `info.stems` before sending, which is what + keeps this plugin correct — `full` already contains every instrument, so if it + ever appeared among the tracks we sum, unity playback would double the whole + song and muting "guitar" would leave guitar audible inside the mix. The old + names are read as a fallback so the plugin still works against a core that + predates the rename; that fallback goes when the aliases do (feedback#945). + - **ES-module migration, step 11.1 — streaming/transport hardening.** (1) Guard `handleNaturalEnd()` on `transport.playing`: in worklet mode a queued `ended` message could arrive just after a user pause/stop flipped `playing=false` and diff --git a/src/main.js b/src/main.js index 253a31f..5e01299 100644 --- a/src/main.js +++ b/src/main.js @@ -76,11 +76,13 @@ import { // to today's AudioBufferSourceNode-per-stem path (speed couples pitch). // 0 = unknown → no compensation until the // worklet's 'ready' message reports it. - // Pristine full-mix track (feedBack#580 / core #583). When a sloppak ships - // a pre-separation `original_audio` mixdown, we load it as one extra worklet - // track and play IT instead of the lossy demucs recombination whenever every - // stem is on at 100% ("unity"); the moment any stem is muted/attenuated we - // cross to the separated stems. Worklet path only; -1 = no full-mix track. + // Pristine full-mix track (feedBack#580 / core #583, #933). When a pack ships + // its pre-separation mixdown — the RESERVED `full` stem (spec §5.3), which + // core surfaces separately from `stems` because it is a mixdown, not a layer + // — we load it as one extra worklet track and play IT instead of the lossy + // demucs recombination whenever every stem is on at 100% ("unity"); the + // moment any stem is muted/attenuated we cross to the separated stems. + // Worklet path only; -1 = no full-mix track. // Mix routing (applyMixRouting + the per-stem gain handle) → src/mix.js; // computeMixGains (pure) → src/mix-gains.js. Both imported above. @@ -657,7 +659,7 @@ import { // Append the pristine full mix as one extra track (index after the // real stems), so unity playback uses it instead of the lossy // recombination — but ONLY when its length matches the stems within - // tolerance. original_audio is a SEPARATE encode (codec priming can + // tolerance. The full mix is a SEPARATE encode (codec priming can // shift it slightly); the transport/highway timeline tracks the // stems, and the worklet ends at its longest track, so a longer mix // would play past the song end and a shorter/wrong one would drop to @@ -672,7 +674,7 @@ import { if (fullBuffer) { const tol = Math.max(2048, Math.round(0.05 * (S.audioCtx ? S.audioCtx.sampleRate : 48000))); if (Math.abs(fullBuffer.length - stemMaxLen) > tol) { - console.warn('[stems] original_audio length off by ' + console.warn('[stems] full mix length off by ' + (fullBuffer.length - stemMaxLen) + ' samples (> ' + tol + '); ignoring it, using separated stems only.'); } else { @@ -801,11 +803,20 @@ import { const gen = S.loadGeneration; S.abortController = new AbortController(); - // Pristine full-mix mixdown, if the pack ships one (core #583 exposes - // it on song_info). Worklet path only — it rides the same time-stretch - // graph as an extra track. A failed/absent full mix degrades silently to - // separated-stems playback (loadFullMix returns null). - const fullUrl = (S.useWorklet && info && info.has_original_audio) ? info.original_audio_url : null; + // Pristine full-mix mixdown, if the pack ships one. This is the RESERVED + // `full` stem (feedpak §5.3), which core lifts out of `info.stems` and + // surfaces separately — it is a mixdown, not a layer, so it must never be + // one of the tracks we sum. Worklet path only: it rides the same + // time-stretch graph as an extra track. A failed/absent full mix degrades + // silently to separated-stems playback (loadFullMix returns null). + // + // `has_original_audio` / `original_audio_url` are the DEPRECATED aliases + // of these two fields, named after a manifest key core invented and the + // spec never had (#933). Kept as a fallback so this plugin still works + // against a core that predates the rename; drop with the aliases. + const hasFullMix = !!(info && (info.has_full_mix || info.has_original_audio)); + const fullMixUrl = info && (info.full_mix_url || info.original_audio_url); + const fullUrl = (S.useWorklet && hasFullMix) ? fullMixUrl : null; // Probe stem[0] to choose the path by Content-Type: the iOS proxy serves // `audio/wav` (raw PCM — streamable, bounded memory); desktop serves diff --git a/src/streaming.js b/src/streaming.js index 05af1ac..f361910 100644 --- a/src/streaming.js +++ b/src/streaming.js @@ -357,7 +357,7 @@ export async function setupStreaming(stems, probeResp, fullUrl, gen) { t.totalFrames = Math.floor(hdr.dataSize / t.byteAlign); fullTrack = t; } else { - if (hdr) console.warn('[stems] original_audio rate ' + if (hdr) console.warn('[stems] full mix rate ' + hdr.sampleRate + ' != ' + ST.streamSampleRate + '; using separated stems only'); try { t.reader.cancel(); } catch (_) {} } @@ -384,7 +384,7 @@ export async function setupStreaming(stems, probeResp, fullUrl, gen) { if (fullTrack) { const tol = Math.max(2048, Math.round(0.05 * ST.streamSampleRate)); if (Math.abs(fullTrack.totalFrames - maxStemFrames) > tol) { - console.warn('[stems] original_audio length off by ' + console.warn('[stems] full mix length off by ' + (fullTrack.totalFrames - maxStemFrames) + ' frames; using separated stems only.'); try { fullTrack.reader.cancel(); } catch (_) {} } else { From 7515cb5f88153f1f69c1bfb82c3ce20755540b13 Mon Sep 17 00:00:00 2001 From: Kris Anderson Date: Mon, 13 Jul 2026 12:29:22 -0400 Subject: [PATCH 2/2] chore: bump plugin version 0.8.1 -> 0.8.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ship the full-mix-is-a-stem change (read full_mix_url with an original_audio_url fallback) under a bumped plugin version. Compatible internal change, so patch. The CHANGELOG [Unreleased] entry is left unstamped — it accumulates other merged-but-unreleased changes and is stamped at release time. Signed-off-by: Kris Anderson --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index 8f45b54..e1e109e 100644 --- a/plugin.json +++ b/plugin.json @@ -1,7 +1,7 @@ { "id": "stems", "name": "Stems Toggle", - "version": "0.8.1", + "version": "0.8.2", "private": false, "standards": ["capability-pipelines.v1", "plugin-runtime-idempotent.v1"], "settings": {