pub struct MicrophoneCompensation {
pub frequencies: Vec<f32>,
pub spl_db: Vec<f32>,
}Expand description
Microphone compensation data (frequency response correction)
Fields§
§frequencies: Vec<f32>Frequency points in Hz
spl_db: Vec<f32>SPL deviation in dB (positive = mic is louder, negative = mic is quieter)
Implementations§
Source§impl MicrophoneCompensation
impl MicrophoneCompensation
Sourcepub fn apply_to_sweep(
&self,
signal: &[f32],
start_freq: f32,
end_freq: f32,
sample_rate: u32,
inverse: bool,
) -> Vec<f32>
pub fn apply_to_sweep( &self, signal: &[f32], start_freq: f32, end_freq: f32, sample_rate: u32, inverse: bool, ) -> Vec<f32>
Apply pre-compensation to a sweep signal
For log sweeps, this modulates the amplitude based on the instantaneous frequency to pre-compensate for the microphone’s response.
§Arguments
signal- The sweep signal to compensatestart_freq- Start frequency of the sweep in Hzend_freq- End frequency of the sweep in Hzsample_rate- Sample rate in Hzinverse- If true, applies inverse compensation (boost where mic is weak)
§Returns
Pre-compensated signal
Sourcepub fn from_file(path: &Path) -> Result<Self, String>
pub fn from_file(path: &Path) -> Result<Self, String>
Load microphone compensation from a CSV or TXT file
File format:
- CSV: frequency_hz,spl_db (with or without header, comma-separated)
- TXT: freq spl (space/tab-separated, no header assumed)
Sourcepub fn interpolate_at(&self, freq: f32) -> f32
pub fn interpolate_at(&self, freq: f32) -> f32
Interpolate compensation value at a given frequency
Uses linear interpolation in dB domain. Returns 0.0 for frequencies outside the calibration range.
Trait Implementations§
Source§impl Clone for MicrophoneCompensation
impl Clone for MicrophoneCompensation
Source§fn clone(&self) -> MicrophoneCompensation
fn clone(&self) -> MicrophoneCompensation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MicrophoneCompensation
impl RefUnwindSafe for MicrophoneCompensation
impl Send for MicrophoneCompensation
impl Sync for MicrophoneCompensation
impl Unpin for MicrophoneCompensation
impl UnwindSafe for MicrophoneCompensation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more