전체 소리 2배: 음량 50이 예전 100 크기로 나오도록 마스터 게인을 음량×2로

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-18 00:11:01 +09:00
parent ca8baf5cc8
commit e9bc366305
3 changed files with 16 additions and 8 deletions

View File

@@ -90,7 +90,12 @@ test('chat sound follows the volume setting and is silent when sound is off', as
setVolume(50);
chatSound();
expect(notes.length).toBeGreaterThan(0);
expect(master!.value).toBe(0.5);
expect(master!.value).toBe(1); // the default 50 plays sounds at their written level
notes = [];
await new Promise((r) => setTimeout(r, 100));
setVolume(100);
chatSound();
expect(master!.value).toBe(2); // 100 is twice as loud
notes = [];
await new Promise((r) => setTimeout(r, 100));
setVolume(50, false);

View File

@@ -1,7 +1,8 @@
/**
* Synthesized sounds + vibration (no audio files; docs/07 §6).
* Every sound goes through one master gain set from the site volume (0~100, default 50; the old sounds at full level
* are now volume 100, so the default plays them at half). Games use `sfx.*` (shared palette) or `tone`/`noise`
* Every sound goes through one master gain set from the site volume (0~100, default 50). The master gain is
* `MASTER_BOOST` × volume, so the default 50 plays the sounds at their written level and 100 plays them twice as loud.
* Games use `sfx.*` (shared palette) or `tone`/`noise`
* directly for something of their own.
*/
import { useEffect, useRef } from 'react';
@@ -10,6 +11,8 @@ import { useSession } from '../store/session';
let ctx: AudioContext | null = null;
let master: GainNode | null = null;
/** Master gain at volume 100 (2 → volume 50 plays every sound at its written level, 100 at double). */
export const MASTER_BOOST = 2;
/** 0~1 from the settings (0 when sound is off). */
export function volume01(): number {
@@ -28,7 +31,7 @@ function audio(): { a: AudioContext; out: GainNode } | null {
master = ctx.createGain();
master.connect(ctx.destination);
}
master.gain.value = v;
master.gain.value = v * MASTER_BOOST;
return { a: ctx, out: master };
} catch {
return null;
@@ -42,7 +45,7 @@ export interface ToneOpts {
attack?: number;
}
/** One enveloped oscillator note. `gain` is the level at volume 100. */
/** One enveloped oscillator note. `gain` is the level at volume 50 (the default). */
export function tone(freq: number, ms: number, type: OscillatorType = 'sine', gain = 0.15, delay = 0, opts: ToneOpts = {}): void {
const au = audio();
if (!au) return;
@@ -189,7 +192,7 @@ export const sounds = {
buzz: () => tone(180, 260, 'square', 0.08),
};
/** The usual level of a game sound at volume 100 (`tone`'s default). */
/** The usual level of a game sound at volume 50 (`tone`'s default). */
export const GAME_LEVEL = 0.15;
/** Chat sound in % of a game sound (admin setting `chatSound`, 0~200, default 80); it also follows the volume setting. */
let chatPercent = CHAT_SOUND_DEFAULT;
@@ -197,7 +200,7 @@ let chatPercent = CHAT_SOUND_DEFAULT;
export function setChatSound(x: unknown): void {
chatPercent = clampChatSound(x);
}
/** Peak level of the chat sound at volume 100 (`percent`: the admin setting unless previewing another value). */
/** Peak level of the chat sound at volume 50 (`percent`: the admin setting unless previewing another value). */
export const chatLevel = (percent = chatPercent): number => (GAME_LEVEL * clampChatSound(percent)) / 100;
let lastChatAt = -Infinity;

View File

@@ -17,7 +17,7 @@
- 디스코드 앱 생성 완료(Client ID `1557009917641105499`). Secret은 서버 `.env`와 호스트 비밀 저장소에만 둔다.
## 0-2. 확정된 결정 (2026-10-13)
- 소리·움직임: 모든 게임. 화면 정보(view) 변화에만 반응해 한 번씩 울리고, 처음 들어올 때·다시 접속·무르기는 조용하다. 승패 소리는 방 화면만 낸다. 숨은 정보는 소리·배너로도 드러내지 않는다. 오디오 파일 없이 합성음만 쓴다. 사이트 음량 0~100(기본 50, 기기별).
- 소리·움직임: 모든 게임. 화면 정보(view) 변화에만 반응해 한 번씩 울리고, 처음 들어올 때·다시 접속·무르기는 조용하다. 승패 소리는 방 화면만 낸다. 숨은 정보는 소리·배너로도 드러내지 않는다. 오디오 파일 없이 합성음만 쓴다. 사이트 음량 0~100(기본 50, 기기별). 50이 합성음을 적힌 크기 그대로, 100이 그 2배로 낸다.
- 시간 "무제한": 시간 제한이 있는 모든 게임에 둔다. 무제한이면 마감·시간 초과가 없고, 연결이 끊긴 사람은 방의 유예 시간 뒤 그 사람 몫만 자동 처리한다. 자리 비움 짧은 마감은 그대로. 마피아·라이어는 단계별로 고르고 모두 마치면 넘어간다(마피아 밤은 직업을 숨기려고 생존자 모두 "밤 마치기"). 그림 맞히기 무제한은 출제자가 정답 공개하고 넘긴다. 판 결과 화면 시간은 무제한 대상이 아니다.
- 원카드: 카드 내기와 [원카드!] 외치기는 따로다(자동 외치기 옵션만 예외). 1장 남은 뒤 2초(1~3초 옵션)는 본인만 누를 수 있고, 그 뒤엔 누구나 잡는다. 컴퓨터는 실력별로 늦게 외치고, 남의 깜빡임은 확률로만 알아챈다. "외치면 다른 사람이 1장씩 먹기" 하우스 룰(기본 끔)도 있다.
- 섯다: 한게임 섯다 방식(2장 한 번에 받기 기본, 20/40장, 베팅 규칙 일반/111~444, 땡잡이 3·7 아무 패, 멍텅구리구사 9땡까지, 쿼터 기본 끔, 숫자 키 베팅). 금액은 "원", 모인 돈은 "판돈"(섯다만 예외, 화폐 기호·현금·머니·충전·환전 같은 낱말은 계속 금지, 놀이용 안내 항상 표시). 예전 칩 방은 ×1000으로 옮긴다. 컴퓨터는 남은 패를 CPU로 전부 세어(크면 표본 3,000판) 기댓값으로 고른다. GPU는 쓰지 않는다(경우의 수가 작아 CPU로 정확히 계산됨, 판단 1번 수 ms).