Add typewriter clatter during text reveal

A dry synthesized key-clack (filtered noise burst with pitch jitter) plays as
each line types out — every other non-space character — for a detective-terminal
feel. Skipped in the editor preview and when reduced-motion is set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 20:24:06 +02:00
co-authored by Claude Opus 4.8
parent 6d4026476e
commit 80e5f548ac
2 changed files with 34 additions and 0 deletions
+7
View File
@@ -84,6 +84,13 @@ export function DialoguePlayer({ node, onExit, inline, startId }: { node: { utte
return () => window.clearInterval(id)
}, [currentId, fullText, reduced]) // eslint-disable-line react-hooks/exhaustive-deps
// Typewriter clatter as characters are revealed (every other non-space char).
useEffect(() => {
if (inline || charCount === 0 || charCount > fullText.length) return
const ch = fullText[charCount - 1]
if (ch && ch !== ' ' && charCount % 2 === 0) audio.type()
}, [charCount]) // eslint-disable-line react-hooks/exhaustive-deps
const pick = (choice: RuntimeUtterance) => {
if (!inline) audio.sfx('choice')
if (choice.childIds.length > 0) setCurrentId(choice.childIds[0])