From f0f8eb6a70804a1295c98c08d4041354052b5e16 Mon Sep 17 00:00:00 2001 From: mattromano <42412983+mattromano@users.noreply.github.com> Date: Fri, 6 Nov 2026 17:42:10 -0800 Subject: [PATCH 1/2] fix(audio): base tones stay off the solo preset; mute the chain during preset swaps - Tone Automation (issue #15): a song's BASE tone named "Lead" or "_solo" was classified as solo, so the whole song played on the solo preset. The switcher now remembers the base tone and gives it the idle (default) target when it classifies as solo, unless the user overrode that tone. Real solo tone changes keep the solo preset. - Preset swaps (issue #16): the engine builds the new chain stage by stage with audio running, so a high-gain amp played ~1 s without its cabinet IR. replaceChainWithPresetBlob mutes the guitar chain gain first; success re-applies the preset level, both failure paths restore the slider level. Fixes #15 Fixes #16 Co-Authored-By: Claude Opus 5.5 --- src/renderer/screen.js | 26 +++++++- tests/preset-swap-mute.test.js | 39 ++++++++++++ tests/tone-automation-base-tone.test.js | 79 +++++++++++++++++++++++++ 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 tests/preset-swap-mute.test.js create mode 100644 tests/tone-automation-base-tone.test.js diff --git a/src/renderer/screen.js b/src/renderer/screen.js index a948531..a52359b 100644 --- a/src/renderer/screen.js +++ b/src/renderer/screen.js @@ -2367,6 +2367,16 @@ window.__feedBackDesktopAudioHooks = window.__feedBackDesktopAudioHooks || {}; try { snapshotBlob = await api.savePreset(); } catch (_) { /* best-effort */ } } + // Mute the guitar chain for the swap (issue #16): the engine builds the new chain stage by + // stage with audio running, so a high-gain amp could play for ~1 s before its cabinet IR + // landed — a burst of harsh, cab-less fizz. applyPresetGainLevels() below restores the + // level on success; every failure path restores the slider's level (the current one). + const restoreChainGain = () => { + const db = parseFloat(outputGainSlider ? outputGainSlider.value : '0'); + try { api.setGain('chain', dbToLinearGain(Number.isFinite(db) ? db : 0)); } catch (_) { /* best-effort */ } + }; + try { await api.setGain('chain', 0); } catch (_) { /* best-effort */ } + try { await api.clearChain(); // Clean any Rig Builder stages a pre-fix build baked into this saved @@ -2390,6 +2400,7 @@ window.__feedBackDesktopAudioHooks = window.__feedBackDesktopAudioHooks || {}; if (result === false || (result && result.success === false)) { console.error(tag + ': loadPreset failed:', result?.error || 'unknown error'); await _restorePresetBlob(snapshotBlob, tag); + restoreChainGain(); if (!snapshotBlob) { // No rollback available; chain is now empty — sync localStorage and UI to match. try { localStorage.setItem('slopsmith-signal-chain', '[]'); } catch (_) {} @@ -2409,6 +2420,7 @@ window.__feedBackDesktopAudioHooks = window.__feedBackDesktopAudioHooks || {}; } catch (e) { console.error(tag + ':', e); await _restorePresetBlob(snapshotBlob, tag); + restoreChainGain(); if (!snapshotBlob) { // No rollback available; chain is now empty — sync localStorage and UI to match. try { localStorage.setItem('slopsmith-signal-chain', '[]'); } catch (_) {} @@ -4219,6 +4231,11 @@ window.__feedBackDesktopAudioHooks = window.__feedBackDesktopAudioHooks || {}; constructor() { this.activeTone = null; this.activePreset = null; + // The song's base tone (issue #15): CDLC authors often name it "Lead" or + // "_solo", which the keyword classifier files under solo, so the whole + // song played on the solo preset. The base tone is the song's default sound — + // it never takes the solo target unless the user overrode it for this tone. + this.baseTone = ''; this.taSwitcher = true; this._switchLock = null; // in-flight Promise; null when idle this._pendingTone = null; // latest request that arrived while locked (coalesced) @@ -4244,7 +4261,13 @@ window.__feedBackDesktopAudioHooks = window.__feedBackDesktopAudioHooks || {}; } async _doSwitch(input) { const cfg = readTaStore(); - const { effectiveName: presetName, autoName, category } = getTaSessionEffectivePreset(input, cfg); + let { effectiveName: presetName, autoName, category } = getTaSessionEffectivePreset(input, cfg); + const ov = (typeof window !== 'undefined') ? window._aeTaSessionOverrides : null; + const userOverride = !!(ov && Object.prototype.hasOwnProperty.call(ov, input) && ov[input]); + if (this.baseTone && input === this.baseTone && category === 'solo' && !userOverride) { + const idle = (cfg.targets || {}).idle; + if (idle) { presetName = idle; autoName = idle; category = 'idle (base tone)'; } + } if (!presetName || presetName === this.activePreset) return; const ok = await loadPresetByName(presetName); if (ok) { @@ -4282,6 +4305,7 @@ window.__feedBackDesktopAudioHooks = window.__feedBackDesktopAudioHooks || {}; return true; } const switcher = new ToneAutomationSwitcher(); + switcher.baseTone = String(toneBase || '').trim(); window._toneSwitcher = switcher; const initialInput = String(toneBase || songKey || '').trim(); if (initialInput) await switcher.switchToTone(initialInput); diff --git a/tests/preset-swap-mute.test.js b/tests/preset-swap-mute.test.js new file mode 100644 index 0000000..3e6f1a1 --- /dev/null +++ b/tests/preset-swap-mute.test.js @@ -0,0 +1,39 @@ +// Issue #16: while a preset loads, the engine builds the chain stage by stage with audio +// running, so a high-gain amp played for ~1 s without its cabinet IR (harsh fizz). The swap +// now mutes the guitar chain first; success restores the preset level, failure the slider's. + +'use strict'; + +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); + +const SRC = fs.readFileSync(path.join(__dirname, '..', 'src', 'renderer', 'screen.js'), 'utf8').replace(/\r\n/g, '\n'); + +function fnBody(name) { + const start = SRC.indexOf(`async function ${name}(`); + assert.ok(start !== -1, `${name} not found`); + let i = SRC.indexOf('{', SRC.indexOf(')', start)) + 1, depth = 1; + while (i < SRC.length && depth > 0) { if (SRC[i] === '{') depth++; else if (SRC[i] === '}') depth--; i++; } + return SRC.slice(start, i); +} + +test('the guitar chain is muted before the old chain is cleared', () => { + const body = fnBody('replaceChainWithPresetBlob'); + const mute = body.indexOf("api.setGain('chain', 0)"); + const clear = body.indexOf('api.clearChain()'); + assert.ok(mute > 0 && clear > mute, 'mute happens before clearChain'); +}); + +test('success restores the preset level after the whole chain is loaded', () => { + const body = fnBody('replaceChainWithPresetBlob'); + assert.ok(body.indexOf('applyPresetGainLevels(preset)') > body.indexOf('api.loadPreset(')); +}); + +test('both failure paths restore the current level (never left silent)', () => { + const body = fnBody('replaceChainWithPresetBlob'); + const restores = body.match(/_restorePresetBlob\(snapshotBlob, tag\);\s*restoreChainGain\(\);/g) || []; + assert.equal(restores.length, 2); + assert.match(body, /const restoreChainGain = \(\) => \{[\s\S]*?outputGainSlider[\s\S]*?api\.setGain\('chain'/); +}); diff --git a/tests/tone-automation-base-tone.test.js b/tests/tone-automation-base-tone.test.js new file mode 100644 index 0000000..b07cf86 --- /dev/null +++ b/tests/tone-automation-base-tone.test.js @@ -0,0 +1,79 @@ +// Issue #15: Tone Automation filed a song's BASE tone under "solo" when its name contained +// "lead"/"solo" (CDLC: "Lead", "mychdead_solo"), so the whole song played on the solo preset. +// The base tone now takes the idle (default) target; real solo tone changes keep solo. + +'use strict'; + +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const vm = require('node:vm'); + +const SRC = fs.readFileSync(path.join(__dirname, '..', 'src', 'renderer', 'screen.js'), 'utf8'); + +function extractClass(src, name) { + const start = src.indexOf(`class ${name} {`); + assert.ok(start !== -1, `class ${name} not found`); + let i = src.indexOf('{', start) + 1, depth = 1; + while (i < src.length && depth > 0) { if (src[i] === '{') depth++; else if (src[i] === '}') depth--; i++; } + return src.slice(start, i); +} + +function harness({ overrides = {} } = {}) { + const loads = []; + const cfg = { enabled: true, targets: { idle: 'Main Lead', solo: 'Metal Lead', dist: 'Main Lead' } }; + const ctx = { + window: { _aeTaSessionOverrides: overrides }, + console: { log() {} }, + readTaStore: () => cfg, + // Stub classifier: "lead"/"solo" in the name -> solo, else idle (mirrors the real keyword split). + getTaSessionEffectivePreset: (t) => { + const category = /lead|solo/i.test(t) ? 'solo' : 'idle'; + const autoName = cfg.targets[category]; + const effectiveName = Object.prototype.hasOwnProperty.call(overrides, t) ? overrides[t] : autoName; + return { autoName, effectiveName, category }; + }, + loadPresetByName: async (n) => { loads.push(n); return true; }, + }; + vm.runInNewContext(`${extractClass(SRC, 'ToneAutomationSwitcher')}; this.S = ToneAutomationSwitcher;`, ctx); + return { S: ctx.S, loads }; +} + +test('a base tone named "Lead" plays the default tone, not the solo preset', async () => { + const { S, loads } = harness(); + const sw = new S(); + sw.baseTone = 'Lead'; + await sw.switchToTone('Lead'); + assert.deepEqual(loads, ['Main Lead']); +}); + +test('a "_solo" base tone is treated the same way', async () => { + const { S, loads } = harness(); + const sw = new S(); + sw.baseTone = 'mychdead_solo'; + await sw.switchToTone('mychdead_solo'); + assert.deepEqual(loads, ['Main Lead']); +}); + +test('a real solo tone change still gets the solo preset, and returning to base goes back', async () => { + const { S, loads } = harness(); + const sw = new S(); + sw.baseTone = 'Lead'; + await sw.switchToTone('Lead'); + await sw.switchToTone('Guitar Solo'); + await sw.switchToTone('Lead'); + assert.deepEqual(loads, ['Main Lead', 'Metal Lead', 'Main Lead']); +}); + +test("the user's own per-tone override still wins", async () => { + const { S, loads } = harness({ overrides: { Lead: 'Metal Lead' } }); + const sw = new S(); + sw.baseTone = 'Lead'; + await sw.switchToTone('Lead'); + assert.deepEqual(loads, ['Metal Lead']); +}); + +test('the install sets the base tone on the switcher', () => { + assert.match(SRC, /const switcher = new ToneAutomationSwitcher\(\);\s*switcher\.baseTone = String\(toneBase \|\| ''\)\.trim\(\);/); +}); From 61f771dc84acba54380e14a3e90d18ec9fa756f4 Mon Sep 17 00:00:00 2001 From: mattromano <42412983+mattromano@users.noreply.github.com> Date: Fri, 6 Nov 2026 17:49:30 -0800 Subject: [PATCH 2/2] build: drop the Stem Mixer plugin from the bundle (one stem control) Stem volume was settable in three places (feedBack-desktop#19). The core Mixer already has a fader per stem (the stems plugin registers them), so the separate Stem Mixer plugin is no longer bundled; the stems plugin's own player-bar row is switched off in mattromano/feedBack-plugin-stems. Fixes #19 Co-Authored-By: Claude Opus 5.5 --- scripts/build-common.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/build-common.sh b/scripts/build-common.sh index a536e2e..570d52d 100644 --- a/scripts/build-common.sh +++ b/scripts/build-common.sh @@ -160,7 +160,6 @@ clone_slopsmith() { mattromano/feedBack-plugin-song-preview:song_preview mattromano/feedBack-plugin-splitscreen@custom:splitscreen mattromano/feedBack-plugin-staffview:staffview - mattromano/feedBack-plugin-stem-mixer:stem_mixer mattromano/feedBack-plugin-stem-splitter:stem_splitter mattromano/feedBack-plugin-stems@custom:stems mattromano/feedBack-plugin-stepmode:stepmode