From e89a1210a15f6b85d55f6be0f58002cee1b2f6b1 Mon Sep 17 00:00:00 2001 From: eve <3vantill@gmail.com> Date: Fri, 2 Oct 2026 16:36:50 -0700 Subject: [PATCH] =?UTF-8?q?live:=20'hear=20it'=20plays=20through=20a=20num?= =?UTF-8?q?bers-station=20chain=20=E2=80=94=20client-side=20DSP:=20soft-cl?= =?UTF-8?q?ip=20crunch,=201700Hz=20shortwave=20bandpass,=20white-noise=20b?= =?UTF-8?q?ed=20with=20propagation=20flutter,=20carrier=20whistle,=20tunin?= =?UTF-8?q?g=20burst=20before=20the=20voice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/live.html | 53 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/site/live.html b/site/live.html index 93c1700..db3e765 100644 --- a/site/live.html +++ b/site/live.html @@ -910,7 +910,7 @@ function showVoice(outEl, text, valence, dose){ fetch(`${API}/speak`, {method:"POST", headers:{"Content-Type":"application/json"}, body: JSON.stringify({text, valence: valence || "pain", dose: dose ?? 0})}) .then(r=> r.ok ? r.blob() : Promise.reject(r.status)) - .then(b=>{ new Audio(URL.createObjectURL(b)).play(); + .then(b=>{ numbersStation(b); vp.textContent = "▶ hear it"; delete vp.dataset.busy; }) .catch(()=>{ vp.textContent = "the voice is resting"; setTimeout(()=>{ vp.textContent = "▶ hear it"; delete vp.dataset.busy; }, 4000); }); @@ -926,6 +926,57 @@ function showVoice(outEl, text, valence, dose){ }) .catch(()=>{ if (v.dataset.for === text) v.remove(); }); } +// numbers-station playback: decode the TTS mp3, then run it through a +// shortwave chain client-side — bitcrush (WaveShaper soft-clip), a narrow +// bandpass like a 7 MHz AM channel, low gain, plus a looped white-noise +// bed with slow flutter and a tuning burst before the voice comes in. +let _ac = null; +function numbersStation(blob){ + _ac = _ac || new (window.AudioContext || window.webkitAudioContext)(); + const ac = _ac; + ac.resume(); + blob.arrayBuffer().then(ab => ac.decodeAudioData(ab)).then(buf => { + const t0 = ac.currentTime + 0.15; + // --- voice chain: clip -> bandpass -> gain + const src = ac.createBufferSource(); src.buffer = buf; + const shaper = ac.createWaveShaper(); + const n = 1024, curve = new Float32Array(n); + for (let i=0;i