Module audio_input

Module audio_input 

Source
Expand description

Real-time audio input capture using cpal.

On Linux, cpal sits on top of ALSA and transparently sees both PulseAudio and PipeWire (via its Pulse compatibility layer) devices. The interesting bit for a music visualizer is selecting the right source: the host’s default input is usually the microphone, but we want the active sink’s monitor so the visualizer reacts to whatever is playing out of the speakers. detect_default_source applies that heuristic — pick the monitor of the default output sink when one exists, otherwise any .monitor source, otherwise the host’s default input. [with_device] uses it transparently when no explicit name is requested.

Structs§

AudioAnalysisInput
Audio input with FFT analysis for bass/mid/treb extraction.
AudioInput
Real-time audio input capture.
AudioSource
A capture device enumerated from the active cpal host.

Enums§

AudioInputError
Audio input errors.
SourceKind
Coarse classification of an input source. Used by the CLI list-audio subcommand and the GUI device picker to flag which devices are monitor sources (capture what speakers play) versus microphones — both surface as cpal Devices with no built-in type tag, so we infer from the name.

Functions§

classify_source 🔒
Classify a device name with the heuristic documented above. Pure function so we can unit-test without a real audio host.
detect_default_source 🔒
Pick the best autodetect source for a music visualizer.
device_name 🔒
Read a cpal Device’s human name through the [DeviceTrait::description] surface (cpal 0.17 deprecates the bare name() accessor). Returns None when the description can’t be fetched — usually because the device was disconnected mid-enumeration.
list_sources
Enumerate every capture source the active cpal host exposes, with classification flags. Cheap (no streams opened); the CLI / GUI device pickers and the autodetect-preview both call this.

Type Aliases§

Result