cepstrum-extractor

Crates.iocepstrum-extractor
lib.rscepstrum-extractor
version0.2.0
created_at2024-06-15 22:30:25.250065+00
updated_at2025-04-15 13:37:47.960825+00
descriptionAn easy-to-use crate to compute the cepstrum of a signal.
homepage
repositoryhttps://github.com/Skilvingr/rust-cepstrum-extractor
max_upload_size
id1273165
size8,594,430
Skilfingr (Skilvingr)

documentation

https://docs.rs/cepstrum-extractor

README

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`
Commit count: 24

cargo fmt