Add the ability to control microphone volume (#287)

Control microphone volume via UI in device page. Set to the maximum by default and saved in preferences to restore upon restarts.
This commit is contained in:
Omar Amin authored and GitHub committed 2026-04-10 01:33:34 +02:00
1 parent 4ee7bb04bc
commit c284806b73
3 files changed
+43 -1

No files matched your search

+3 -1
View File
@@ -375,6 +375,7 @@ async def main() -> None:
output_only=args.output_only,
download_dir=args.download_dir,
volume=initial_volume,
mic_volume=preferences.mic_volume,
mic_auto_gain=preferences.mic_auto_gain,
mic_noise_suppression=preferences.mic_noise_suppression,
timer_max_ring_seconds=args.timer_max_ring_seconds,
@@ -455,7 +456,8 @@ def process_audio(state: ServerState, mic, block_size: int):
while True:
audio_chunk_array = mic_in.record(block_size).reshape(-1)
# little-endian 16-bit signed
audio_chunk = (np.clip(audio_chunk_array, -1.0, 1.0) * 32767.0).astype("<i2").tobytes()
mic_vol_scalar = max(0.1, min(1.0, state.mic_volume / 100.0))
audio_chunk = (np.clip(audio_chunk_array * mic_vol_scalar, -1.0, 1.0) * 32767.0).astype("<i2").tobytes()
if state.satellite is None:
continue