Skip to main content

math_audio_dsp/
lib.rs

1//! DSP utilities for audio signal processing
2//!
3//! This crate provides:
4//! - **Signal generation**: Test signals (tones, sweeps, noise)
5//! - **Signal analysis**: FFT-based frequency analysis, microphone compensation
6//! - **Acoustic metrics**: RT60, clarity (C50/C80), THD, spectrogram
7//!
8//! # Example
9//!
10//! ```rust
11//! use math_audio_dsp::{signals, analysis};
12//!
13//! // Generate a 1 kHz tone
14//! let signal = signals::gen_tone(1000.0, 0.5, 48000, 1.0);
15//!
16//! // Analyze a WAV file
17//! let config = analysis::WavAnalysisConfig::default();
18//! // let result = analysis::analyze_wav_buffer(&signal, 48000, &config);
19//! ```
20
21pub mod analysis;
22pub mod audio_features;
23pub mod binaural_matrix;
24pub mod ebur128;
25pub mod esprit;
26pub mod fast_math;
27pub mod fdn;
28pub mod fdw;
29pub mod instantaneous_frequency;
30pub mod psychoacoustics;
31pub mod replaygain;
32pub mod response;
33pub mod rtpghi;
34pub mod signals;
35pub mod simd;
36pub mod stft;
37pub mod tonal_transient;
38pub mod waveform;
39
40// DSP building blocks (moved from sotf-host)
41pub mod adaa;
42pub mod auto_makeup;
43pub mod channel_linking;
44pub mod dc_blocker;
45pub mod delta_monitor;
46pub mod detector;
47pub mod dynamics_core;
48pub mod envelope;
49pub mod envelope_follower;
50pub mod lookahead;
51pub mod smoothing;
52pub mod true_peak;
53
54// Re-export commonly used types
55pub use analysis::{
56    AnalysisResult, CrossCorrelationEnvelopeResult, MicrophoneCompensation, WavAnalysisConfig,
57    WavAnalysisOutput, WindowedFrequencyResponse, analyze_recording, analyze_wav_buffer,
58    analyze_wav_file, compute_average_response, compute_clarity_broadband,
59    compute_clarity_spectrum, compute_group_delay, compute_impulse_response_from_fr,
60    compute_rt60_broadband, compute_rt60_spectrum, compute_spectrogram, compute_windowed_fr,
61    cross_correlate_envelope, find_db_point, read_analysis_csv, smooth_response_f32,
62    smooth_response_f64, write_analysis_csv, write_wav_analysis_csv,
63};
64
65pub use fdw::{FdwAnalysis, FdwConfig, analyze_impulse_response_fdw};
66
67pub use binaural_matrix::{
68    MatrixInverseBin, TransferMatrixBin, align_ir_to_reference_peak, condition_number,
69    deconvolve_sweep_to_ir, direct_peak_sample, direct_peak_windowed_half_spectrum,
70    direct_windowed_half_spectrum, fdw_complex_half_spectrum, half_spectrum_to_fir,
71    position_errors, solve_minimax_regularized_inverse_bin, solve_regularized_inverse_bin,
72    solve_weighted_regularized_inverse_bin, suppress_log_sweep_harmonic_residues,
73};
74
75pub use signals::{
76    add_silence_padding, apply_fade_in, apply_fade_out, clip, frames_for, gen_allpass_probe,
77    gen_dirac, gen_log_sweep, gen_m_noise, gen_mls, gen_narrowband_probe, gen_pink_noise, gen_tone,
78    gen_two_tone, gen_white_noise, interleave_per_channel, mono_to_stereo,
79    prepare_signal_for_playback, prepare_signal_for_playback_channels, replicate_mono,
80};
81
82pub use replaygain::{ReplayGainAnalyzer, ReplayGainInfo, ReplayGainTrackData, compute_album_gain};
83pub use response::{biquad_complex_response, fir_complex_response, lr4_crossover_response};
84pub use waveform::{WAVEFORM_SAMPLES, compute_waveform};