From 0f2ec9be858ce1af2a3342d2632fc4b5ce31d47d Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Mon, 20 Apr 2026 16:05:11 -0700 Subject: [PATCH] notepat: fix `pf is not defined` ReferenceError in sample wave blip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit playWaveSound("sample") referenced `pf` (pitch factor), a local binding that only exists inside playZoo / playLaser / playPercussion — not in playWaveSound's scope. Switching wavetype to "sample" threw a ReferenceError on the very first synth call, which the error display surfaced as "act: pf not defined" because the act() handler is what invokes setWave() → playWaveSound(). The pitch-factor is meaningless for a 30 ms UI-confirmation click, so drop the multiplication and use the literal 800 Hz tone. Co-Authored-By: Claude Opus 4.7 (1M context) --- fedac/native/pieces/notepat.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fedac/native/pieces/notepat.mjs b/fedac/native/pieces/notepat.mjs index 540578baf0..a0788e2f63 100644 --- a/fedac/native/pieces/notepat.mjs +++ b/fedac/native/pieces/notepat.mjs @@ -1961,8 +1961,11 @@ function hitTestGrid(x, y, gi) { function playWaveSound(sound, waveType) { if (!sound?.synth) return; if (waveType === "sample") { - // Short percussive click for sample mode - sound.synth({ type: "noise", tone: 800 * pf, duration: 0.03, volume: 0.12, attack: 0.001, decay: 0.025, pan: 0 }); + // Short percussive click for sample mode. Previously this referenced + // `pf` (a local from playZoo/playLaser/playPercussion that never made + // it into this scope) — throwing a ReferenceError the moment anyone + // switched wave to "sample". Plain tone is fine for a UI blip. + sound.synth({ type: "noise", tone: 800, duration: 0.03, volume: 0.12, attack: 0.001, decay: 0.025, pan: 0 }); return; } const tones = { sine: 660, triangle: 550, sawtooth: 440, square: 330, harp: 440, whistle: 880 }; -- 2.51.2