#[non_exhaustive]pub struct MicrophoneConfig {
pub sample_rate: u32,
pub channels: u16,
pub frames_per_buffer: u32,
pub device: DeviceSelector,
pub dc_removal: bool,
pub denoise: Option<DenoiseModel>,
pub denoise_model_path: Option<PathBuf>,
pub ort_library_path: Option<PathBuf>,
pub highpass: Option<HighpassFilter>,
pub agc: Option<i8>,
pub limiter: Option<f32>,
}Expand description
Configuration for a microphone capture session.
#[non_exhaustive]: construct it with MicrophoneConfig::default and then
assign the public fields you need. Direct struct-literal construction from
another crate is intentionally not supported, so adding a field later stays
backward compatible.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sample_rate: u32Sample rate in Hz. Range: 1000–384000. Default: 16000.
channels: u16Number of input channels. Mono only: the only accepted value is 1
(the default), and a value greater than 1 is rejected by
validate with
DecibriError::MultichannelNotSupported. The field is kept (rather
than removed) for forward compatibility: a future release may honour a
value greater than 1 by delivering true interleaved multichannel, which
widens the accepted set without breaking callers. Default: 1.
frames_per_buffer: u32Frames per audio callback buffer. Range: 64–65536. Default: 1600.
device: DeviceSelectorDevice selection. Default: system default input.
dc_removal: boolRemove a constant (DC) offset from captured audio with a one-pole DC-blocking high-pass, applied after the channel and rate normalization. Default: false (off).
denoise: Option<DenoiseModel>Single-channel speech-enhancement (denoise) model to run on the captured
audio, applied after DC removal. None (the default) leaves denoise off.
Naming a model also requires denoise_model_path;
with the model set but no path the stage stays off. Honoured only when the
denoise feature is compiled in.
denoise_model_path: Option<PathBuf>Filesystem path to the denoise model’s ONNX file, supplied by the caller
(the bindings resolve it from their bundled copy; the core ships no model
bytes). Required when denoise names a model; ignored
otherwise. Default: None.
ort_library_path: Option<PathBuf>Filesystem path to the ONNX Runtime dynamic library, used to initialise
ORT for the capture-path denoise stage (the same role
VadConfig::ort_library_path
plays for the VAD). Consulted only when denoise names a
model and the denoise feature is compiled with ort-load-dynamic; under
ort-download-binaries ORT is statically linked and this is ignored.
None (the default) leaves ORT to its own discovery (the ORT_DYLIB_PATH
environment variable, then the system loader). ORT initialises once per
process (first-wins), so when a VAD has already initialised it this is a
no-op. Default: None.
highpass: Option<HighpassFilter>High-pass filter to apply to the captured audio, removing low-frequency
rumble below the voice band. Runs in the transform chain after denoise,
on the cleaned mono signal at the target rate. None (the default)
builds no high-pass stage, leaving the captured audio full-range (a true
byte-identical no-op). Pure DSP: it loads no model and needs no path.
agc: Option<i8>Automatic gain control target level in dBFS, applied to the captured
audio. Drives the running level toward this target with a smoothed,
rate-limited gain. Range: -40 to -3 dBFS (typical -18). None (the
default) builds no level-control stage, leaving the level untouched (a
true byte-identical no-op). Runs after the high-pass step, honoured only
when the gain feature is compiled in. Pure DSP: no model, no path.
limiter: Option<f32>Peak limiter ceiling in dBFS (sample-peak), applied to the captured audio.
Holds the signal at or below this ceiling, the safety net that catches a
transient the AGC’s gain would let exceed full scale. Range: -3.0 to 0.0
dBFS (typical -1.0). None (the default) builds no limiter stage, leaving
the level untouched (a true byte-identical no-op). Runs last in the
transform chain, after the level-control step, honoured only when the
gain feature is compiled in. Pure DSP: no model, no path.
Implementations§
Source§impl MicrophoneConfig
impl MicrophoneConfig
Sourcepub fn validate(&self) -> Result<(), DecibriError>
pub fn validate(&self) -> Result<(), DecibriError>
Validate the configuration: sample rate, channel count, buffer size, the AGC target, and the limiter ceiling (each when set) must fall within the supported ranges.
Trait Implementations§
Source§impl Clone for MicrophoneConfig
impl Clone for MicrophoneConfig
Source§fn clone(&self) -> MicrophoneConfig
fn clone(&self) -> MicrophoneConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more