Rescale mic calibration gain range and defaults

This commit is contained in:
Jage9
2026-02-22 16:24:27 -05:00
parent cfb70ec04e
commit 2f82e107ff
2 changed files with 6 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version. // Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2) // Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
window.CHGRID_WEB_VERSION = "2026.02.22 R149"; window.CHGRID_WEB_VERSION = "2026.02.22 R150";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid. // Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit"; window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -68,10 +68,11 @@ const NICKNAME_STORAGE_KEY = 'spatialChatNickname';
const NICKNAME_MAX_LENGTH = 32; const NICKNAME_MAX_LENGTH = 32;
const MIC_CALIBRATION_DURATION_MS = 5000; const MIC_CALIBRATION_DURATION_MS = 5000;
const MIC_CALIBRATION_SAMPLE_INTERVAL_MS = 50; const MIC_CALIBRATION_SAMPLE_INTERVAL_MS = 50;
const MIC_CALIBRATION_MIN_GAIN = 0.25; const MIC_CALIBRATION_MIN_GAIN = 0.5;
const MIC_CALIBRATION_MAX_GAIN = 3; const MIC_CALIBRATION_MAX_GAIN = 4;
const MIC_CALIBRATION_TARGET_RMS = 0.12; const MIC_CALIBRATION_TARGET_RMS = 0.12;
const MIC_CALIBRATION_ACTIVE_RMS_THRESHOLD = 0.003; const MIC_CALIBRATION_ACTIVE_RMS_THRESHOLD = 0.003;
const MIC_INPUT_GAIN_SCALE_MULTIPLIER = 2;
declare global { declare global {
interface Window { interface Window {
@@ -445,7 +446,7 @@ function clampMicInputGain(value: number): number {
function loadMicInputGain(): void { function loadMicInputGain(): void {
const raw = localStorage.getItem(MIC_INPUT_GAIN_STORAGE_KEY); const raw = localStorage.getItem(MIC_INPUT_GAIN_STORAGE_KEY);
if (!raw) { if (!raw) {
audio.setOutboundInputGain(1); audio.setOutboundInputGain(2);
return; return;
} }
const parsed = Number(raw); const parsed = Number(raw);
@@ -1085,7 +1086,7 @@ async function calibrateMicInputGain(): Promise<void> {
return; return;
} }
const calibratedGain = clampMicInputGain(MIC_CALIBRATION_TARGET_RMS / observedRms); const calibratedGain = clampMicInputGain((MIC_CALIBRATION_TARGET_RMS / observedRms) * MIC_INPUT_GAIN_SCALE_MULTIPLIER);
const appliedGain = audio.setOutboundInputGain(calibratedGain); const appliedGain = audio.setOutboundInputGain(calibratedGain);
persistMicInputGain(appliedGain); persistMicInputGain(appliedGain);
updateStatus(`Mic calibration set to ${appliedGain.toFixed(2)}x.`); updateStatus(`Mic calibration set to ${appliedGain.toFixed(2)}x.`);