ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
lib/options/registry/audio.c
Go to the documentation of this file.
1
12
13#include <options/registry/common.h>
14#include <options/registry/metadata.h>
15
16#include <options/parsers.h>
17#include <limits.h>
18
19// ============================================================================
20// AUDIO CATEGORY - Audio processing options
21// ============================================================================
22static bool validate_audio_fft_size(const void *data) {
23 const options_t *options = data;
24 if (options->audio_fft_size == 512 || options->audio_fft_size == 1024 || options->audio_fft_size == 2048)
25 return true;
26 SET_ERRNO(ERROR_USAGE, "--audio-fft-size must be 512, 1024, or 2048");
27 return false;
28}
29
30static const bool default_audio_spectral = true;
31static const bool default_audio_spectral_mixer = false;
32static const bool default_audio_spectral_gate = true;
33static const bool default_audio_multiband = false;
34static const bool default_audio_adaptive_eq = false;
35static const int default_audio_fft_size = 1024;
36static const bool default_audio_pitch_correct = false;
37static const bool default_audio_spectral_agc = false;
38static const bool default_reduce_noise = true;
39static const bool default_test_audio = false;
41 {"test-audio",
42 '\0',
44 offsetof(options_t, test_audio),
45 &default_test_audio,
46 sizeof(bool),
47 "Send a gentle repeating test signal instead of microphone audio and monitor it on speakers; enables audio.",
48 "AUDIO",
49 NULL,
50 false,
51 "ASCII_CHAT_TEST_AUDIO",
52 NULL,
53 NULL,
54 false,
55 false,
57 {0},
58 NULL},
59 {"audio-spectral-agc",
60 '\0',
62 offsetof(options_t, audio_spectral_agc),
63 &default_audio_spectral_agc,
64 sizeof(bool),
65 "Enable spectral RMS gain control with --spectral-audio.",
66 "AUDIO",
67 NULL,
68 false,
69 "ASCII_CHAT_AUDIO_SPECTRAL_AGC",
70 NULL,
71 NULL,
72 false,
73 false,
75 {0},
76 NULL},
77 {"audio-pitch-correct",
78 '\0',
80 offsetof(options_t, audio_pitch_correct),
81 &default_audio_pitch_correct,
82 sizeof(bool),
83 "Experimental monophonic semitone correction with --spectral-audio.",
84 "AUDIO",
85 NULL,
86 false,
87 "ASCII_CHAT_AUDIO_PITCH_CORRECT",
88 NULL,
89 NULL,
90 false,
91 false,
93 {0},
94 NULL},
95 {"spectral-audio",
96 '\0',
98 offsetof(options_t, audio_spectral),
99 &default_audio_spectral,
100 sizeof(bool),
101 "Process microphone audio with FFTW (default on; media/test audio bypass it). Disable with "
102 "--spectral-audio=false.",
103 "AUDIO",
104 NULL,
105 false,
106 "ASCII_CHAT_SPECTRAL_AUDIO",
107 NULL,
108 NULL,
109 false,
110 false,
112 {0},
113 NULL},
114 {"reduce-noise",
115 '\0',
117 offsetof(options_t, reduce_noise),
118 &default_reduce_noise,
119 sizeof(bool),
120 "Enable neural microphone noise reduction for client-like modes; disable with --reduce-noise=false.",
121 "AUDIO",
122 NULL,
123 false,
124 "ASCII_CHAT_REDUCE_NOISE",
125 NULL,
126 NULL,
127 false,
128 false,
130 {0},
131 NULL},
132 {"audio-spectral-mixer",
133 '\0',
135 offsetof(options_t, audio_spectral_mixer),
136 &default_audio_spectral_mixer,
137 sizeof(bool),
138 "Opt in to FFTW processing of the entire server mix, including media and test signals (default off).",
139 "AUDIO",
140 NULL,
141 false,
142 "ASCII_CHAT_AUDIO_SPECTRAL_MIXER",
143 NULL,
144 NULL,
145 false,
146 false,
148 {0},
149 NULL},
150 {"audio-spectral-gate",
151 '\0',
153 offsetof(options_t, audio_spectral_gate),
154 &default_audio_spectral_gate,
155 sizeof(bool),
156 "Enable adaptive spectral noise reduction with --spectral-audio.",
157 "AUDIO",
158 NULL,
159 false,
160 "ASCII_CHAT_AUDIO_SPECTRAL_GATE",
161 NULL,
162 NULL,
163 false,
164 false,
166 {0},
167 NULL},
168 {"audio-multiband",
169 '\0',
171 offsetof(options_t, audio_multiband),
172 &default_audio_multiband,
173 sizeof(bool),
174 "Enable four-band compression with --spectral-audio.",
175 "AUDIO",
176 NULL,
177 false,
178 "ASCII_CHAT_AUDIO_MULTIBAND",
179 NULL,
180 NULL,
181 false,
182 false,
184 {0},
185 NULL},
186 {"audio-adaptive-eq",
187 '\0',
189 offsetof(options_t, audio_adaptive_eq),
190 &default_audio_adaptive_eq,
191 sizeof(bool),
192 "Enable bounded spectral EQ balancing with --spectral-audio.",
193 "AUDIO",
194 NULL,
195 false,
196 "ASCII_CHAT_AUDIO_ADAPTIVE_EQ",
197 NULL,
198 NULL,
199 false,
200 false,
202 {0},
203 NULL},
204 {"audio-fft-size",
205 '\0',
207 offsetof(options_t, audio_fft_size),
208 &default_audio_fft_size,
209 sizeof(int),
210 "Spectral FFT size: 512, 1024, or 2048 (latency versus frequency resolution).",
211 "AUDIO",
212 NULL,
213 false,
214 "ASCII_CHAT_AUDIO_FFT_SIZE",
215 validate_audio_fft_size,
216 NULL,
217 false,
218 false,
220 {0},
221 NULL},
222 // AUDIO GROUP (client, discovery)
223 {"audio",
224 'A',
226 offsetof(options_t, audio_enabled),
227 &default_audio_enabled_value,
228 sizeof(bool),
229 "Enable audio streaming (press 'm' during rendering to toggle).",
230 "AUDIO",
231 NULL,
232 false,
233 "ASCII_CHAT_AUDIO",
234 NULL,
235 NULL,
236 false,
237 false,
239 {0},
240 NULL},
241 {"microphone-channels",
242 '\0',
244 offsetof(options_t, microphone_channels),
245 &(const int){1},
246 sizeof(int),
247 "Microphone layout: 1 for centered speech, 2 for a stereo pair.",
248 "AUDIO",
249 NULL,
250 false,
251 "ASCII_CHAT_MICROPHONE_CHANNELS",
252 NULL,
253 NULL,
254 false,
255 false,
257 {.numeric_range = {1, 2, 1}, .input_type = OPTION_INPUT_NUMERIC},
258 NULL},
259 {"microphone-channel",
260 '\0',
262 offsetof(options_t, microphone_channel),
263 &(const int){0},
264 sizeof(int),
265 "First zero-based microphone channel; -1 averages all inputs to mono.",
266 "AUDIO",
267 NULL,
268 false,
269 "ASCII_CHAT_MICROPHONE_CHANNEL",
270 NULL,
271 NULL,
272 false,
273 false,
275 {.numeric_range = {-1, 63, 1}, .input_type = OPTION_INPUT_NUMERIC},
276 NULL},
277 {"microphone-index",
278 '\0',
280 offsetof(options_t, microphone_index),
281 &default_microphone_index_value,
282 sizeof(int),
283 "Microphone device index for audio input.",
284 "AUDIO",
285 NULL,
286 false,
287 "ASCII_CHAT_MICROPHONE_INDEX",
288 NULL,
289 NULL,
290 false,
291 false,
293 {.numeric_range = {-1, INT_MAX, 1}, .examples = g_mic_examples, .input_type = OPTION_INPUT_NUMERIC},
294 NULL},
295 {"speakers-index",
296 '\0',
298 offsetof(options_t, speakers_index),
299 &default_speakers_index_value,
300 sizeof(int),
301 "Speakers device index to use for audio output.",
302 "AUDIO",
303 NULL,
304 false,
305 "ASCII_CHAT_SPEAKERS_INDEX",
306 NULL,
307 NULL,
308 false,
309 false,
311 {.numeric_range = {-1, 10, 1}, .examples = g_speakers_examples, .input_type = OPTION_INPUT_NUMERIC},
312 NULL},
313 {"microphone-volume",
314 '\0',
316 offsetof(options_t, microphone_sensitivity),
317 &default_microphone_sensitivity_value,
318 sizeof(float),
319 "Microphone volume multiplier (0.0-1.0).",
320 "AUDIO",
321 NULL,
322 false,
323 "ASCII_CHAT_MICROPHONE_VOLUME",
324 NULL,
326 false,
327 false,
329 {.numeric_range = {0, 1, 0}},
330 NULL},
331 {"ivolume",
332 '\0',
334 offsetof(options_t, microphone_sensitivity),
335 &default_microphone_sensitivity_value,
336 sizeof(float),
337 "Alias for --microphone-volume.",
338 "AUDIO",
339 NULL,
340 false,
341 "ASCII_CHAT_IVOLUME",
342 NULL,
344 false,
345 false,
347 {.numeric_range = {0, 1, 0}},
348 NULL},
349 {"speakers-volume",
350 '\0',
352 offsetof(options_t, speakers_volume),
353 &default_speakers_volume_value,
354 sizeof(float),
355 "Speakers volume multiplier (0.0-1.0; press =/- during rendering to adjust).",
356 "AUDIO",
357 NULL,
358 false,
359 "ASCII_CHAT_SPEAKERS_VOLUME",
360 NULL,
362 false,
363 false,
365 {.numeric_range = {0, 1, 0}},
366 NULL},
367 {"volume",
368 '\0',
370 offsetof(options_t, speakers_volume),
371 &default_speakers_volume_value,
372 sizeof(float),
373 "Alias for --speakers-volume.",
374 "AUDIO",
375 NULL,
376 false,
377 "ASCII_CHAT_VOLUME",
378 NULL,
380 false,
381 false,
383 {.numeric_range = {0, 1, 0}},
384 NULL},
385 {"audio-source",
386 '\0',
388 offsetof(options_t, audio_source),
389 &default_audio_source_value,
390 sizeof(audio_source_t),
391 "Select audio shown by --waveform/--fft: all (default), call, mic, or media.",
392 "AUDIO",
393 NULL,
394 false,
395 "ASCII_CHAT_AUDIO_SOURCE",
396 NULL,
398 false,
399 false,
401 {.enum_values = g_audio_source_values, .enum_descriptions = g_audio_source_descs, .enum_integer_values = g_audio_source_integers, .input_type = OPTION_INPUT_ENUM},
402 NULL},
403 {"audio-capture-source",
404 '\0',
406 offsetof(options_t, audio_capture_source),
407 &default_audio_capture_source_value,
409 "Select local audio capture and media playback: auto, mic, media, both, or remote.",
410 "AUDIO",
411 NULL,
412 false,
413 "ASCII_CHAT_AUDIO_CAPTURE_SOURCE",
414 NULL,
416 false,
417 false,
419 {.enum_values = g_audio_capture_source_values, .enum_descriptions = g_audio_capture_source_descs, .enum_integer_values = g_audio_capture_source_integers, .input_type = OPTION_INPUT_ENUM},
420 NULL},
421#ifdef DEBUG
422 {"audio-analysis",
423 '\0',
425 offsetof(options_t, audio_analysis_enabled),
426 &default_audio_analysis_value,
427 sizeof(bool),
428 "Enable audio analysis (debug).",
429 "AUDIO",
430 NULL,
431 false,
432 "ASCII_CHAT_AUDIO_ANALYSIS",
433 NULL,
434 NULL,
435 false,
436 false,
438 {0},
439 NULL},
440#endif
441 {"no-audio-playback",
442 '\0',
444 offsetof(options_t, audio_no_playback),
445 &default_no_audio_playback_value,
446 sizeof(bool),
447 "Disable speakers output.",
448 "AUDIO",
449 NULL,
450 false,
451 "ASCII_CHAT_NO_AUDIO_PLAYBACK",
452 NULL,
453 NULL,
454 false,
455 false,
457 {0},
458 NULL},
459 {"encode-audio",
460 '\0',
462 offsetof(options_t, encode_audio),
463 &default_encode_audio_value,
464 sizeof(bool),
465 "Enable Opus audio encoding.",
466 "AUDIO",
467 NULL,
468 false,
469 "ASCII_CHAT_ENCODE_AUDIO",
470 NULL,
471 NULL,
472 false,
473 false,
475 {0},
476 NULL},
477 {"no-encode-audio",
478 '\0',
480 offsetof(options_t, encode_audio),
481 &default_no_encode_audio_value,
482 sizeof(bool),
483 "Disable Opus audio encoding.",
484 "AUDIO",
485 NULL,
486 false,
487 "ASCII_CHAT_NO_ENCODE_AUDIO",
488 NULL,
489 NULL,
490 false,
491 false,
493 {0},
494 NULL},
495 {"no-audio-mixer",
496 '\0',
498 offsetof(options_t, no_audio_mixer),
499 &default_no_audio_mixer_value,
500 sizeof(bool),
501 "Use simple audio mixing without ducking or compression (debug mode only).",
502 "AUDIO",
503 NULL,
504 false,
505 "ASCII_CHAT_NO_AUDIO_MIXER",
506 NULL,
507 NULL,
508 false,
509 false,
511 {0},
512 NULL},
513 {"list-microphones",
514 '\0',
516 0,
517 NULL,
518 0,
519 "List available audio input devices by index and exit.",
520 "AUDIO",
521 NULL,
522 false,
523 NULL,
524 NULL,
525 NULL,
526 false,
527 false,
529 {0},
530 NULL},
531 {"list-speakers",
532 '\0',
534 0,
535 NULL,
536 0,
537 "List available audio output devices by index and exit.",
538 "AUDIO",
539 NULL,
540 false,
541 NULL,
542 NULL,
543 NULL,
544 false,
545 false,
547 {0},
548 NULL},
549
#define SET_ERRNO(code,...)
@ OPTION_INPUT_NUMERIC
Numeric value with optional min/max/step.
Definition builder.h:188
@ OPTION_INPUT_ENUM
Choose from fixed set of enum values.
Definition builder.h:187
@ OPTION_TYPE_INT
Integer value (–count 42).
Definition builder.h:172
@ OPTION_TYPE_ACTION
Action that executes and may exit (–list-webcams, etc.).
Definition builder.h:176
@ OPTION_TYPE_CALLBACK
Custom parser function.
Definition builder.h:175
@ OPTION_TYPE_BOOL
Boolean flag (–flag, no value).
Definition builder.h:171
@ ERROR_USAGE
Definition error_codes.h:52
audio_capture_source_t
Definition options.h:291
struct options_state options_t
Immutable, RCU-published snapshot of the application's runtime configuration.
audio_source_t
Audio source selected for visualization.
Definition options.h:277
@ OPTION_MODE_BINARY
Binary-level options (parsed before mode detection).
Definition options.h:942
@ OPTION_MODE_CLIENT
Client mode (bit 1).
Definition options.h:936
@ OPTION_MODE_DISCOVERY
Discovery mode (bit 4).
Definition options.h:939
@ OPTION_MODE_SERVER
Server mode (bit 0).
Definition options.h:935
@ OPTION_MODE_MIRROR
Mirror mode (bit 2).
Definition options.h:937
const registry_entry_t g_audio_entries[]
#define REGISTRY_TERMINATOR()
Initialize a terminator entry (sentinel value for array end) Uses designated initializers to properly...
const char * g_audio_capture_source_values[]
Definition metadata.c:124
const char * g_audio_source_descs[]
Definition metadata.c:121
const char * g_speakers_examples[]
Definition metadata.c:150
const int g_audio_capture_source_integers[]
Definition metadata.c:126
const char * g_audio_source_values[]
Definition metadata.c:119
const char * g_mic_examples[]
Definition metadata.c:149
const char * g_audio_capture_source_descs[]
Definition metadata.c:127
const int g_audio_source_integers[]
Definition metadata.c:120
bool parse_audio_source(const char *arg, void *dest, char **error_msg)
Parse visualization source option (–audio-source).
Definition parsers.c:1095
bool parse_audio_capture_source(const char *arg, void *dest, char **error_msg)
Definition parsers.c:1130
bool parse_volume(const char *arg, void *dest, char **error_msg)
Custom parser for volume options (–volume, –speakers-volume, –microphone-volume).
Definition parsers.c:1023
Custom option parsers for enum types.
int audio_fft_size
Definition options.h:1112
Registry entry - stores option definition with mode bitmask and metadata.