diff --git a/web/src/App.tsx b/web/src/App.tsx index 28f4336..0378102 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -7308,9 +7308,9 @@ function AppInner() { // Off by default: a heavier, opt-in alternative/supplement to native AEC for // speaker+mic (no headset) setups (github.com/WebSpeak3/webspeak3 issue #2). const [aec3Enabled, setAec3Enabled] = useState(() => loadBoolPref(AEC3_ENABLED_KEY, false)); - // Playback options, defaults as in TS3. + // Playback options. The clicks themselves are sounds (micClickOn/Off). const [autoVolume, setAutoVolume] = useState(() => loadBoolPref(AUTO_VOLUME_KEY, true)); - const [ownMicClicks, setOwnMicClicks] = useState(() => loadBoolPref(OWN_MIC_CLICKS_KEY, true)); + const [ownMicClicks, setOwnMicClicks] = useState(() => loadBoolPref(OWN_MIC_CLICKS_KEY, false)); const [otherMicClicks, setOtherMicClicks] = useState(() => loadBoolPref(OTHER_MIC_CLICKS_KEY, false)); // Read from the socket handler, which only sees the first render's state. const otherMicClicksRef = useRef(otherMicClicks); @@ -8233,8 +8233,8 @@ function AppInner() { const prev = talkersRef.current; if (otherMicClicksRef.current && !outputMutedRef.current) { // One click per update, even if several people start at once. - if ([...next].some((id) => !prev.has(id))) audioPlayerRef.current?.playMicClick(true); - else if ([...prev].some((id) => !next.has(id))) audioPlayerRef.current?.playMicClick(false); + if ([...next].some((id) => !prev.has(id))) void playSound("micClickOn"); + else if ([...prev].some((id) => !next.has(id))) void playSound("micClickOff"); } talkersRef.current = next; setTalkers(next); @@ -10418,7 +10418,7 @@ function AppInner() { selfTalkingSeenRef.current = true; return; } - if (ownMicClicks && !outputMuted) audioPlayerRef.current?.playMicClick(selfTalking); + if (ownMicClicks && !outputMuted) void playSound(selfTalking ? "micClickOn" : "micClickOff"); }, [selfTalking]); // eslint-disable-line react-hooks/exhaustive-deps const showServerQueryClients = activeFavoriteId != null && diff --git a/web/src/locales/cs-CZ.json b/web/src/locales/cs-CZ.json index 756a34f..6781e57 100644 --- a/web/src/locales/cs-CZ.json +++ b/web/src/locales/cs-CZ.json @@ -667,6 +667,8 @@ "sounds.event.message": "Přijata zpráva", "sounds.event.poke": "Přijato šťouchnutí", "sounds.event.mute": "Přepnutí ztlumení", + "sounds.event.micClickOn": "Kliknutí mikrofonu zap.", + "sounds.event.micClickOff": "Kliknutí mikrofonu vyp.", "sounds.default": "Výchozí", "sounds.custom": "Vlastní soubor: {name}", "sounds.test": "▶ Test", diff --git a/web/src/locales/de.json b/web/src/locales/de.json index 72b0399..0651a9e 100644 --- a/web/src/locales/de.json +++ b/web/src/locales/de.json @@ -667,6 +667,8 @@ "sounds.event.message": "Nachricht empfangen", "sounds.event.poke": "Anstupsen erhalten", "sounds.event.mute": "Stummschaltung umgeschaltet", + "sounds.event.micClickOn": "Mikro Klick an", + "sounds.event.micClickOff": "Mikro Klick aus", "sounds.default": "Standard", "sounds.custom": "Eigene Datei: {name}", "sounds.test": "▶ Testen", diff --git a/web/src/locales/en.json b/web/src/locales/en.json index cc7d5ed..6af076b 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -667,6 +667,8 @@ "sounds.event.message": "Message received", "sounds.event.poke": "Poke received", "sounds.event.mute": "Mute toggled", + "sounds.event.micClickOn": "Mic click on", + "sounds.event.micClickOff": "Mic click off", "sounds.default": "Default", "sounds.custom": "Custom file: {name}", "sounds.test": "▶ Test", diff --git a/web/src/locales/fa.json b/web/src/locales/fa.json index 4744519..d14e07d 100644 --- a/web/src/locales/fa.json +++ b/web/src/locales/fa.json @@ -666,6 +666,8 @@ "sounds.event.message": "پیام دریافت شد", "sounds.event.poke": "سقلمه دریافت شد", "sounds.event.mute": "تغییر حالت بی‌صدا", + "sounds.event.micClickOn": "کلیک میکروفون روشن", + "sounds.event.micClickOff": "کلیک میکروفون خاموش", "sounds.default": "پیش‌فرض", "sounds.custom": "فایل سفارشی: {name}", "sounds.test": "▶ آزمایش", diff --git a/web/src/locales/zh-CN.json b/web/src/locales/zh-CN.json index 0c558f4..0daced3 100644 --- a/web/src/locales/zh-CN.json +++ b/web/src/locales/zh-CN.json @@ -512,6 +512,8 @@ "sounds.event.message": "收到消息", "sounds.event.poke": "收到戳一戳", "sounds.event.mute": "切换静音", + "sounds.event.micClickOn": "麦克风开启提示音", + "sounds.event.micClickOff": "麦克风关闭提示音", "sounds.default": "默认", "sounds.custom": "自定义文件:{name}", "sounds.test": "▶ 测试", diff --git a/web/src/soundpack.ts b/web/src/soundpack.ts index acbd265..80ccedf 100644 --- a/web/src/soundpack.ts +++ b/web/src/soundpack.ts @@ -24,6 +24,8 @@ const EVENT_KEYWORDS: Record = { message: ["textmessagereceived", "chatmessage", "newmessage", "message"], poke: ["gotpoked", "poke"], mute: ["micmuted", "microphonemuted", "micactivated", "microphoneactivated"], + micClickOn: ["micclickon"], + micClickOff: ["micclickoff"], }; function normalize(filename: string): string { diff --git a/web/src/sounds.ts b/web/src/sounds.ts index a11414c..4e6378b 100644 --- a/web/src/sounds.ts +++ b/web/src/sounds.ts @@ -1,6 +1,25 @@ -export type SoundEventId = "connect" | "disconnect" | "clientJoin" | "clientLeave" | "message" | "poke" | "mute"; +export type SoundEventId = + | "connect" + | "disconnect" + | "clientJoin" + | "clientLeave" + | "message" + | "poke" + | "mute" + | "micClickOn" + | "micClickOff"; -export const SOUND_EVENTS: SoundEventId[] = ["connect", "disconnect", "clientJoin", "clientLeave", "message", "poke", "mute"]; +export const SOUND_EVENTS: SoundEventId[] = [ + "connect", + "disconnect", + "clientJoin", + "clientLeave", + "message", + "poke", + "mute", + "micClickOn", + "micClickOff", +]; /** "ide" swaps the default chimes for synthetic terminal blips (Command Center layout). */ type SoundStyle = "classic" | "ide"; @@ -215,6 +234,10 @@ function synthNotes(event: SoundEventId): SynthNote[] { ]; case "mute": return [{ delay: 0, freq: 660, duration: 0.06, gain: 0.3 }]; + case "micClickOn": + return [{ delay: 0, freq: 1400, duration: 0.03, gain: 0.15 }]; + case "micClickOff": + return [{ delay: 0, freq: 900, duration: 0.03, gain: 0.15 }]; } } @@ -247,6 +270,10 @@ function ideNotes(event: SoundEventId): SynthNote[] { ]; case "mute": return [{ delay: 0, freq: 300, endFreq: 50, duration: 0.04, gain: 0.15, type: "square" }]; + case "micClickOn": + return [{ delay: 0, freq: 1600, duration: 0.02, gain: 0.08, type: "square" }]; + case "micClickOff": + return [{ delay: 0, freq: 1000, duration: 0.02, gain: 0.08, type: "square" }]; } } diff --git a/web/src/voice.ts b/web/src/voice.ts index 90ce515..299dc14 100644 --- a/web/src/voice.ts +++ b/web/src/voice.ts @@ -447,25 +447,16 @@ export class AudioPlayer { /** Plays a short sine-wave test tone through the same volume/output-device routing as voice playback. */ playTestTone(): void { - this.beep(440, 0.6, 0.3); - } - - /** Short tick when someone starts (higher) or stops (lower) talking. */ - playMicClick(start: boolean): void { - this.beep(start ? 1400 : 900, 0.03, 0.15); - } - - private beep(freq: number, duration: number, volume: number): void { const osc = this.context.createOscillator(); osc.type = "sine"; - osc.frequency.value = freq; + osc.frequency.value = 440; const toneGain = this.context.createGain(); - toneGain.gain.value = volume; + toneGain.gain.value = 0.3; osc.connect(toneGain); toneGain.connect(this.gain); const now = this.context.currentTime; osc.start(now); - osc.stop(now + duration); + osc.stop(now + 0.6); osc.onended = () => { osc.disconnect(); toneGain.disconnect();