Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
35 changes: 23 additions & 12 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (_) {}
}
Expand All @@ -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 {
Expand Down
Loading