#extractor #cepstrum #quefrency #cepstral

cepstrum-extractor

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

5 releases

new 0.1.4 Nov 20, 2024
0.1.3 Oct 30, 2024
0.1.2 Jun 18, 2024
0.1.1 Jun 17, 2024
0.1.0 Jun 15, 2024

#211 in Audio

Download history 2/week @ 2024-09-18 7/week @ 2024-09-25 4/week @ 2024-10-09 4/week @ 2024-10-16 126/week @ 2024-10-30 9/week @ 2024-11-06

140 downloads per month

MIT/Apache

8.5MB
300 lines

Cepstrum Extractor

crates.io Documentation Rust + Miri

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

For more info about the concept of cepstrum, here's the original paper.

Usage

Quite a simple crate: create a CepstrumExtractor with a given length and use it to compute real or complex cepstrum of a signal.

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

Such slices also implement traits with windowing functions, at the moment only one is available: Hann.

A note about the length of the results:

As for spectrums, only the first half of the result of a fft has meaningful values. Cepstrums are computed with a fft, so here it's the same.

Methods that return a vec already truncate the result to half the input slice, but *_mut methods, the ones which mutate the slice passed as input, clearly can't, so pay attention to what you do when using these methods.

Example:

Given a CepstrumExtractor with len equal to 128, rceps_mut mutates the input slice (long 128 samples as well), but only the first 64 samples of the mutated slice really 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 that can be shared between the threads with a simple Arc; more info about this are available in the relative docs page.

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

Tests and examples

Miri test can be found within script.

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

Tests can be run with:

cargo test

Concurrent example can be run with:

cargo run --example concurrent

Other examples can be run with:

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

Dependencies