diff --git a/neode-ui/src/composables/useLoginSounds.ts b/neode-ui/src/composables/useLoginSounds.ts index 6483b476..f4c9a990 100644 --- a/neode-ui/src/composables/useLoginSounds.ts +++ b/neode-ui/src/composables/useLoginSounds.ts @@ -172,27 +172,31 @@ export function playTypingTick() { a.play().catch(() => {}) } -/** Keyboard input sound - plays on any character typed in inputs. Separate from typing tick/intro typing. */ -let keyboardInputPool: HTMLAudioElement[] = [] -const KEYBOARD_INPUT_POOL_SIZE = 5 - -function getKeyboardInputSound(): HTMLAudioElement { - if (keyboardInputPool.length === 0) { - for (let i = 0; i < KEYBOARD_INPUT_POOL_SIZE; i++) { - const a = new Audio('/assets/audio/typing.mp3') - a.volume = 0.5 - keyboardInputPool.push(a) - } - } - const a = keyboardInputPool.shift()! - keyboardInputPool.push(a) - return a -} - +/** Keyboard input sound - short synthesized click per key. Does NOT use typing.mp3 or intro-typing.mp3. */ export function playKeyboardTypingSound() { - const a = getKeyboardInputSound() - a.currentTime = 0 - a.play().catch(() => {}) + const ctx = getContext() + if (!ctx) return + + try { + if (ctx.state === 'suspended') ctx.resume() + } catch { + return + } + + const t = ctx.currentTime + const osc = ctx.createOscillator() + const gain = ctx.createGain() + + osc.type = 'sine' + osc.frequency.setValueAtTime(1200, t) + gain.gain.setValueAtTime(0, t) + gain.gain.linearRampToValueAtTime(0.06, t + 0.002) + gain.gain.exponentialRampToValueAtTime(0.001, t + 0.04) + + osc.connect(gain) + gain.connect(ctx.destination) + osc.start(t) + osc.stop(t + 0.04) } /** Gaming-style boot thud - soft impact when dashboard loads */