DASP-RS: Digital Audio Signal Processing for Rust
dasp-rs is a crate for digital audio signal processing for developers, researchers, phoneticians, and students.
Table of Contents
Features
- Audio I/O: Load and export WAV files with flexible resampling and channel conversion.
- Signal Processing: Arithmetic operations, mixing, panning, and resampling for audio signals.
- Feature Extraction: Spectral, harmonic, rhythm, and manipulation features for advanced analysis.
- Time-Frequency Analysis: STFT, CQT, VQT, and more with phase recovery and reassignment.
- Signal Generation: Tones, chirps, and clicks for testing and synthesis.
- Parallelization: Multi-core processing with
rayonfor efficiency. - Error Handling: Robust error types with detailed diagnostics using
thiserror. - Testing: Unit tests for core functionality to ensure reliability.
Installation
Dependencies
This crate requires OpenBLAS and pkg-config to be installed on your system before building. The build links to your system OpenBLAS and does not download anything when the library is found. If the build attempts to download OpenBLAS, the system library was not detected (install OpenBLAS and pkg-config, or set PKG_CONFIG_PATH if installed in a custom location).
Linux (Arch/Manjaro):
Linux (Debian/Ubuntu):
macOS:
Windows: OpenBLAS is typically provided via vcpkg or you can download pre-built binaries.
Verify: Before building, ensure pkg-config can find OpenBLAS (avoids network download and "Connection refused" errors):
Cargo
Add dasp-rs to your Cargo.toml:
[]
= "0.2.0"
Modules
| Module | Description |
|---|---|
core::io |
WAV I/O with streaming and preprocessing (resampling, mono conversion). |
core::ops |
Sample-wise operations (mix, subtract, multiply, etc.). |
features::harmonics |
Harmonic analysis and phase vocoding. |
features::inverse |
MFCC and mel spectrogram inversion to audio. |
features::manipulation |
Temporal context stacking and statistical features (e.g., kurtosis). |
features::rhythm |
Tempo estimation and tempogram computation. |
features::spectral |
Spectral features (chroma, MFCC, centroid, etc.). |
pitch::tuning |
Pitch detection (YIN, pYIN) and tuning estimation. |
magnitude::scaling |
Amplitude/power to dB conversion and perceptual weighting. |
signal_generation::generators |
Signal generators (tones, chirps, clicks). |
signal_processing::time_frequency |
STFT, CQT, VQT, and other time-frequency transforms. |
signal_processing::mixing |
Stereo, multi-channel, and dry/wet mixing. |
signal_processing::mono |
Mono signal utility to stereo. |
signal_processing::time_domain |
Time-domain processing (e.g., autocorrelation). |
signal_processing::resampling |
Sample rate conversion utilities. |
utils::frequency |
Frequency-related utilities (e.g., FFT bin frequencies). |
utils::notation |
Music notation conversions (e.g., Hz to MIDI). |
utils::time |
Time-related utilities (e.g., frame-to-time mapping). |
Discover more on crates https://crates.io/crates/dasp-rs/ and docs https://docs.rs/dasp-rs/0.2.0.
Example
use load;
use stft;
Performance
- Parallelization: Uses
rayonfor multi-core efficiency. - Memory Efficiency: Lazy streaming for large files.
- Numerical Stability: Built on
ndarray.
Contributing
Submit pull requests or issues to the GitHub repository. Follow Rust conventions and include tests.
Contributing steps:
- Fork the repository.
- Create a branch:
git checkout -b feature-name. - Commit:
git commit -m "Add feature". - Push:
git push origin feature-name. - Open a pull request.
License
dasp-rs is licensed under the GPLv3 License. See LICENSE for details.