Skip to main content

MicrophoneConfig

Struct MicrophoneConfig 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§sample_rate: u32

Sample rate in Hz. Range: 1000–384000. Default: 16000.

§channels: u16

Number 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: u32

Frames per audio callback buffer. Range: 64–65536. Default: 1600.

§device: DeviceSelector

Device selection. Default: system default input.

§dc_removal: bool

Remove 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

Source

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

Source§

fn clone(&self) -> MicrophoneConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MicrophoneConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for MicrophoneConfig

Source§

fn default() -> MicrophoneConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more