@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 13 lines 544 Bytes
Raw
1 export const VOICE_WAVEFORM_SAMPLE_COUNT = 64;
2
3 const VOICE_NOISE_FLOOR_DECIBELS = -60;
4 const VOICE_NOISE_FLOOR_AMPLITUDE = 10 ** (VOICE_NOISE_FLOOR_DECIBELS / 20);
5
6 export function normalizeVoiceInputDecibels(decibels: number | undefined) {
7 if (decibels === undefined || !Number.isFinite(decibels)) return 0;
8 if (decibels <= VOICE_NOISE_FLOOR_DECIBELS) return 0;
9 if (decibels >= 0) return 1;
10
11 const amplitude = 10 ** (decibels / 20);
12 return Math.sqrt((amplitude - VOICE_NOISE_FLOOR_AMPLITUDE) / (1 - VOICE_NOISE_FLOOR_AMPLITUDE));
13 }