1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//! # DASP-RS: Digital Audio Signal Processing in Rust
//!
//! DASP-RS provides a collection of tools and utilities for audio signal processing,
//! analysis, and generation. It includes functionality for handling audio input/output,
//! performing signal transformations, generating synthetic signals, extracting audio features,
//! working with magnitude spectra, and pitch-related operations. The library is designed
//! to be modular and extensible, leveraging Rust's performance and safety features.
//!
//! ## Key Features
//! - Audio I/O: Loading and saving audio files with flexible options.
//! - Signal Processing: Time-frequency transforms (e.g., STFT, CQT) and filtering.
//! - Signal Generation: Creating synthetic waveforms and noise.
//! - Feature Extraction: Computing audio features like tempo, pitch, and spectral properties.
//! - Magnitude Operations: Manipulating and analyzing magnitude spectra.
//! - Pitch Utilities: Converting between frequency, MIDI, and musical notations.
//! - Utilities: General-purpose functions for audio analysis and conversion.
//!
//! ## Usage
//! To use this library, add it to your `Cargo.toml` and import the desired modules:
//!
//! ```toml
//! [dependencies]
//! dasp-rs = "0.4"
//! ```
//!
//! ```no_run
//! // Option 1: Use prelude for convenience
//! use dasp_rs::prelude::*;
//!
//! let audio = Decoder::new("example.wav")
//! .sample_rate(22050)
//! .mono()
//! .load()?;
//!
//! let duration = get_duration(&audio);
//! println!("Duration: {} seconds", duration);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! ```no_run
//! // Option 2: Explicit imports for clarity
//! use dasp_rs::{types::AudioData, io::{Decoder, export}, util::get_duration};
//!
//! let audio = Decoder::new("example.wav")
//! .sample_rate(22050)
//! .mono()
//! .load()?;
//!
//! let duration = get_duration(&audio);
//! println!("Duration: {} seconds", duration);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! ## API Structure
//! The API is organized by concern for clarity and discoverability:
//! - `prelude` - Convenient imports for common use cases
//! - `types` - Core audio data types (`AudioData`, `AudioError`)
//! - `io` - Audio input/output operations
//! - `proc` - Signal processing algorithms
//! - `feat` - Audio feature extraction
//! - `util` - Utility functions
//! - `pitch` - Pitch detection and conversion
//! - `mag` - Magnitude spectrum operations
//! - `generate` - Signal generation
// Internal modules
/// Core audio data types
/// Audio input/output operations
/// Sample-wise signal operations
/// Signal processing algorithms
/// Audio feature extraction
/// Magnitude spectrum operations
/// Pitch detection and conversion
/// Utility functions
/// Signal generation
/// Prelude module for convenient imports.
///
/// This module re-exports the most commonly used types and functions
/// to make it easier to use the library without verbose imports.
///
/// # Example
/// ```no_run
/// use dasp_rs::prelude::*;
///
/// // Now you can use common items directly
/// let audio = Decoder::new("file.wav").mono().load()?;
/// let duration = get_duration(&audio);
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```