diff --git a/apps/web/src/lib/feedback.test.ts b/apps/web/src/lib/feedback.test.ts index 80bdd4b..bbae23b 100644 --- a/apps/web/src/lib/feedback.test.ts +++ b/apps/web/src/lib/feedback.test.ts @@ -67,19 +67,19 @@ beforeEach(() => { notes = []; }); -test('chat sound is 10% under the game sounds', () => { +test('chat sound is 60% of the game sounds', () => { expect(GAME_LEVEL).toBe(0.15); - expect(CHAT_LEVEL).toBeCloseTo(GAME_LEVEL * 0.9, 10); + expect(CHAT_LEVEL).toBeCloseTo(GAME_LEVEL * 0.6, 10); setVolume(100); sounds.myTurn(); // a typical game sound at the usual level const game = Math.max(...notes.map((n) => n.peak)); notes = []; chatSound(); - // Notes playing at the same moment add up; the loudest moment of the chat sound is 90% of a game sound. + // Notes playing at the same moment add up; the loudest moment of the chat sound is 60% of a game sound. const byStart = new Map(); for (const n of notes) byStart.set(n.start, (byStart.get(n.start) ?? 0) + n.peak); const loudest = Math.max(...byStart.values()); - expect(loudest).toBeCloseTo(game * 0.9, 6); + expect(loudest).toBeCloseTo(game * 0.6, 6); // One bubble ("뽁") gliding up from a low start. expect(notes.map((n) => n.freq)).toEqual([380]); expect(notes.map((n) => n.to)).toEqual([1150]); diff --git a/apps/web/src/lib/feedback.ts b/apps/web/src/lib/feedback.ts index db90b7b..013fbe3 100644 --- a/apps/web/src/lib/feedback.ts +++ b/apps/web/src/lib/feedback.ts @@ -190,21 +190,21 @@ export const sounds = { /** The usual level of a game sound at volume 100 (`tone`'s default). */ export const GAME_LEVEL = 0.15; -/** Chat sound: 10% under the game sounds (it follows the same volume setting). */ -export const CHAT_LEVEL = GAME_LEVEL * 0.9; +/** Chat sound: 60% of the game sounds (it follows the same volume setting); 90% hit the ears too hard. */ +export const CHAT_LEVEL = GAME_LEVEL * 0.6; let lastChatAt = -Infinity; /** * Chat "뽁": one water-drop bubble like a messenger, a sine gliding up fast from low (about 0.08 s). * Kept apart from the UI/game sounds, which are steady notes (click, good, myTurn …), so it is not mistaken for one; * it also starts lower and is shorter and softer than the game "pop" (700→1400 Hz). - * It peaks at CHAT_LEVEL. Lines arriving in a burst share one sound. + * It peaks at CHAT_LEVEL and fades in over 12 ms so it does not snap. Lines arriving in a burst share one sound. */ export function chatSound(): void { const now = performance.now(); if (now - lastChatAt < 80) return; lastChatAt = now; - tone(380, 80, 'sine', CHAT_LEVEL, 0, { attack: 2, slideTo: 1150 }); + tone(380, 80, 'sine', CHAT_LEVEL, 0, { attack: 12, slideTo: 1150 }); } /** Plays the chat sound whenever `lastKey` (the newest live chat line) changes after the first render. */