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_loudness;
24pub mod binaural_matrix;
25pub mod ebur128;
26pub mod esprit;
27pub mod fast_math;
28pub mod fdn;
29pub mod fdw;
30pub mod instantaneous_frequency;
31pub mod psychoacoustics;
32pub mod replaygain;
33pub mod response;
34pub mod rtpghi;
35pub mod signals;
36pub mod simd;
37pub mod stft;
38pub mod tonal_transient;
39pub mod waveform;
40
41// DSP building blocks (moved from sotf-host)
42pub mod adaa;
43pub mod auto_makeup;
44pub mod channel_linking;
45pub mod dc_blocker;
46pub mod delta_monitor;
47pub mod detector;
48pub mod dynamics_core;
49pub mod envelope;
50pub mod envelope_follower;
51pub mod lookahead;
52pub mod smoothing;
53pub mod true_peak;
54
55// Re-export commonly used types
56pub use analysis::{
57    AnalysisResult, CrossCorrelationEnvelopeResult, MicrophoneCompensation, WavAnalysisConfig,
58    WavAnalysisOutput, WindowedFrequencyResponse, analyze_recording, analyze_wav_buffer,
59    analyze_wav_file, compute_average_response, compute_clarity_broadband,
60    compute_clarity_spectrum, compute_group_delay, compute_impulse_response_from_fr,
61    compute_rt60_broadband, compute_rt60_spectrum, compute_spectrogram, compute_windowed_fr,
62    cross_correlate_envelope, find_db_point, read_analysis_csv, smooth_response_f32,
63    smooth_response_f64, write_analysis_csv, write_wav_analysis_csv,
64};
65
66pub use fdw::{FdwAnalysis, FdwConfig, analyze_impulse_response_fdw};
67
68pub use binaural_loudness::{
69    BinauralChannel, BinauralDownmix, BinauralLoudness, BinauralLoudnessResult, SurroundLayout,
70    measure_binaural, measure_binaural_from_surround,
71};
72
73pub use binaural_matrix::{
74    MatrixInverseBin, TransferMatrixBin, align_ir_to_reference_peak, condition_number,
75    deconvolve_sweep_to_ir, direct_peak_sample, direct_peak_windowed_half_spectrum,
76    direct_windowed_half_spectrum, fdw_complex_half_spectrum, half_spectrum_to_fir,
77    position_errors, solve_minimax_regularized_inverse_bin, solve_regularized_inverse_bin,
78    solve_weighted_regularized_inverse_bin, suppress_log_sweep_harmonic_residues,
79};
80
81pub use signals::{
82    add_silence_padding, apply_fade_in, apply_fade_out, clip, frames_for, gen_allpass_probe,
83    gen_dirac, gen_log_sweep, gen_m_noise, gen_mls, gen_narrowband_probe, gen_pink_noise, gen_tone,
84    gen_two_tone, gen_white_noise, interleave_per_channel, mono_to_stereo,
85    prepare_signal_for_playback, prepare_signal_for_playback_channels, replicate_mono,
86};
87
88pub use replaygain::{ReplayGainAnalyzer, ReplayGainInfo, ReplayGainTrackData, compute_album_gain};
89pub use response::{biquad_complex_response, fir_complex_response, lr4_crossover_response};
90pub use waveform::{WAVEFORM_SAMPLES, compute_waveform};