Learning guide
A short, runnable course in speech and audio processing built on audio_samples.
| # | Chapter | Rust lab |
|---|---|---|
| 01 | Sampling and aliasing | cargo run --release --example tutorial_01_sampling_aliasing --features educational,full_no_plotting |
| 02 | Quantisation and dither | cargo run --release --example tutorial_02_quantisation_dither --features educational,full_no_plotting |
| 03 | The DFT, windows and leakage | cargo run --release --example tutorial_03_dft_windows --features educational,full_no_plotting |
| 04 | STFT and spectrograms | cargo run --release --example tutorial_04_stft_spectrograms --features educational,full_no_plotting |
| 05 | Convolution and FIR filters | cargo run --release --example tutorial_05_convolution_fir --features educational,full_no_plotting |
| 06 | IIR filters: design, poles, zeros and stability | cargo run --release --example tutorial_06_iir_filters --features educational,full_no_plotting |
| 07 | Resampling | cargo run --release --example tutorial_07_resampling --features educational,full_no_plotting |
| 08 | LPC, the source-filter model and formants | cargo run --release --example tutorial_08_lpc_formants --features educational,full_no_plotting |
| 09 | Pitch: autocorrelation and YIN | cargo run --release --example tutorial_09_pitch --features educational,full_no_plotting |
| 10 | Cepstrum, mel and MFCC | cargo run --release --example tutorial_10_cepstrum_mel_mfcc --features educational,full_no_plotting |
| 11 | Short-time energy, zero crossings and VAD | cargo run --release --example tutorial_11_energy_vad --features educational,full_no_plotting |
| 12 | Dynamics: compressors and limiters | cargo run --release --example tutorial_12_dynamics --features educational,full_no_plotting |
| 13 | Onsets and tempo | cargo run --release --example tutorial_13_onsets_tempo --features educational,full_no_plotting |
| 14 | Psychoacoustics and codecs | cargo run --release --example tutorial_14_psychoacoustics_codecs --features educational,full_no_plotting |
See also For instructors.
Reading the guide
The chapters are the Markdown files in documentation/guide/, with standard
LaTeX maths ($...$ inline, $$...$$ display). They are published three ways
from the same files:
- in the API documentation, as the
audio_samples::guidemodule (cargo doc --open --features educational,full_no_plotting), where every code block is a doctest; - as an illustrated book with figures computed by the library
(
book/README.mdin the repository says how to build it); - as plain Markdown, readable in any Markdown viewer with maths support.
In the raw Markdown, code lines that start with # are setup lines that
rustdoc hides.
The labs are the files examples/tutorial_NN_<topic>.rs; run them from a
checkout of this repository with the commands in the table. A matching Python
notebook for each chapter is in the Python bindings’ documentation
(docs/source/tutorials/).
Setting up
Every code block in the guide is a doctest of this crate. To compile the
snippets in a crate of your own, add these dependencies to its Cargo.toml
(the versions are the ones this crate itself builds against):
[dependencies]
audio_samples = { version = "3", features = ["educational", "full_no_plotting"] }
spectrograms = "2.2.1" # StftParams, WindowType, MelParams, LogParams, ...
ndarray = "0.17" # Array1 and the array! macro
num-complex = "0.4" # complex numbers in the "How it works" sections
non-empty-slice = "0.6" # NonEmptySlice / NonEmptyVec arguments
audio_samples does not re-export these crates, so they must be listed
explicitly, with compatible versions: the StftParams you pass to stft, for
example, must come from the same spectrograms release that audio_samples
uses. If the audio_samples release on crates.io does not include the guide
and the educational feature, use a path dependency on a checkout of this
repository instead
(audio_samples = { path = "../audio_samples", features = [...] }).
The guide’s signals are all generated in code. To analyse your own
recordings, read WAV or FLAC files with the companion crate
audio_samples_io, whose
read function returns an AudioSamples value.