lasprs/
lib.rs

1//! # Library for acoustic signal processing
2//!
3//! This crate contains structures and functions to perform acoustic
4//! measurements, interact with data acquisition devices and apply common
5//! acoustic analysis operations on them.
6//!
7//! You will find the following stuff in this crate:
8//!
9//! - Data acquisition, recording, signal generation: [daq].
10//! - Power spectra estimation, transfer function estimation tools: [ps].
11//! - Sound Level Meter implementation: [slm].
12//! - Filter design tools. I.e. [filter::ZPKModel::butter].
13//!   - Includes bilinear transforms
14//! - Tools for real time displaying of sensor data: [rt].
15//!
16//! ## Note to potential users
17//!
18//! **This crate is still under heavy development. API changes happen on the
19//! fly. Documentation is not finished. Use with caution and expect things to be
20//! broken and buggy. Use at your own risk and responsibility.**
21//!
22//! ## Author information
23//!
24//! The main developer is J.A. de Jong from [ASCEE](https://www.ascee.nl). In
25//! case of bug reports, please file them to [info@ascee.nl](info@ascee.nl).
26//!
27//! If you have particular interest in this library, please also contact us.
28//!
29#![warn(missing_docs)]
30#![allow(non_snake_case)]
31#![allow(non_upper_case_globals)]
32#![allow(unused_imports)]
33#![allow(clippy::module_inception)]
34mod config;
35use cfg_if::cfg_if;
36use config::*;
37use filter::*;
38
39pub use config::Flt;
40pub mod daq;
41pub mod filter;
42mod math;
43pub mod ps;
44pub mod rt;
45pub mod siggen;
46pub mod slm;
47mod tools;
48
49/// A Python module implemented in Rust.
50#[cfg(all(
51    feature = "python-bindings",
52    not(feature = "python-bindings-nostandalone")
53))]
54#[pymodule]
55#[pyo3(name = "_lasprs")]
56fn lasprs(m: &Bound<'_, PyModule>) -> PyResult<()> {
57    add_lasprs_base_module_components(m)
58}
59
60#[cfg(feature = "python-bindings")]
61/// Adds all LaspRS classes and functions to the base module.
62pub fn add_lasprs_base_module_components(m: &Bound<'_, PyModule>) -> PyResult<()> {
63    daq::add_py_classses(m)?;
64
65    // Add filter submodule
66    m.add_class::<filter::Biquad>()?;
67    m.add_class::<filter::SeriesBiquad>()?;
68    m.add_class::<filter::BiquadBank>()?;
69    m.add_class::<filter::FilterSpec>()?;
70    m.add_class::<filter::ZPKModel>()?;
71    m.add_class::<filter::StandardFilterDescriptor>()?;
72
73    // Signal generator
74    m.add_class::<siggen::Siggen>()?;
75    m.add_class::<siggen::SiggenCommand>()?;
76    m.add_class::<siggen::SweepType>()?;
77    m.add_class::<siggen::SiggenCommand>()?;
78    m.add_class::<siggen::Source>()?;
79
80    // SLM
81    m.add_class::<slm::TimeWeighting>()?;
82    m.add_class::<slm::SLMSettings>()?;
83    m.add_class::<slm::SLM>()?;
84    m.add_class::<slm::TimeWeighting>()?;
85
86    // Power spectra classes
87    m.add_class::<ps::FreqWeighting>()?;
88    m.add_class::<ps::WindowType>()?;
89    m.add_class::<ps::Overlap>()?;
90    m.add_class::<ps::ApsMode>()?;
91    m.add_class::<ps::ApsSettings>()?;
92    m.add_class::<ps::AvPowerSpectra>()?;
93
94    // Real time classes
95    m.add_class::<rt::PPMWrapper>()?;
96    m.add_class::<rt::PPMDropSpeed>()?;
97    m.add_class::<rt::ClipState>()?;
98    m.add_class::<rt::RtAps>()?;
99    m.add_class::<rt::RtViewer>()?;
100
101    Ok(())
102}
103
104cfg_if! {
105    if #[cfg(all(feature = "python-bindings", not(feature = "python-bindings-nostandalone")))] {
106        use pyo3_stub_gen::define_stub_info_gatherer;
107        define_stub_info_gatherer!(stub_info);
108    }
109}