#extractor #cepstrum #quefrency #cepstral

cepstrum-extractor

An easy-to-use crate to compute the cepstrum of a signal

7 releases

new 0.2.0 Apr 15, 2025
0.1.5 Apr 4, 2025
0.1.4 Nov 20, 2024
0.1.3 Oct 30, 2024
0.1.2 Jun 18, 2024

#269 in Audio

Download history 5/week @ 2024-12-27 5/week @ 2025-01-03 10/week @ 2025-01-10 3/week @ 2025-02-14 1/week @ 2025-02-21 3/week @ 2025-02-28 140/week @ 2025-04-04 97/week @ 2025-04-11

237 downloads per month

MIT/Apache

8.5MB
389 lines

Cepstrum Extractor

crates.io Documentation Rust + Miri

An easy-to-use crate to compute the cepstrum of a signal.

For more information about the concept of cepstrum, refer to this original paper.

Usage

This crate is quite simple to use: create a CepstrumExtractor with a specified length and use it to compute the real or complex cepstrum of a signal.

The extractor accepts a slice of Complex as input. The method RealToComplex::to_complex_vec creates a new vector of Complex starting from a slice of f32 or f64.

These slices also implement windowing functions; more information can be found in the related module windows.

A Note About the Length of the Results

As with spectrums, only the first half of the result of an FFT has meaningful values. Cepstrums are computed using an FFT, so the same applies here.

Methods that return a vector already truncate the result to half the input slice. However, *_mut methods, which mutate the slice passed as input, cannot do this, so please pay attention when using these methods.

Example

Given a CepstrumExtractor with a length equal to 128, the rceps_mut method mutates the input slice (which should also be 128 samples long), but only the first 64 samples of the mutated slice actually represent the cepstrum.

A Note About Multithreading

This crate can also be used in a concurrent environment. Only one instance of the extractor is needed, and it can be shared between threads using a simple Arc. More information about this can be found in the relevant documentation page.

An example can be found in the example folder, under the name concurrent.

Tests and Examples

Miri tests can be found in the scripts directory.

The following commands must be run from the root of the crate.

Tests can be run with:

cargo test

Benchmarks can be run with:

cargo bench

The concurrent example can be run with:

RUSTFLAGS="--cfg examples" cargo run --example concurrent

Other examples can be run with:

RUSTFLAGS="--cfg examples" cargo run --example `example_name`

Dependencies