mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Mic clicks as regular sounds, own clicks off by default
The two clicks now live in the sound settings (toggle, test, custom file, soundpack import via mic_click_on/off) instead of being fixed tones in the voice player. Own mic clicks start off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
97421ff2de
commit
341a1644a6
9 files changed
+49
-19
No files matched your search
+5
-5
@@ -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 &&
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": "▶ آزمایش",
|
||||
|
||||
@@ -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": "▶ 测试",
|
||||
|
||||
@@ -24,6 +24,8 @@ const EVENT_KEYWORDS: Record<SoundEventId, string[]> = {
|
||||
message: ["textmessagereceived", "chatmessage", "newmessage", "message"],
|
||||
poke: ["gotpoked", "poke"],
|
||||
mute: ["micmuted", "microphonemuted", "micactivated", "microphoneactivated"],
|
||||
micClickOn: ["micclickon"],
|
||||
micClickOff: ["micclickoff"],
|
||||
};
|
||||
|
||||
function normalize(filename: string): string {
|
||||
|
||||
+29
-2
@@ -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" }];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-12
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user