cepstrum-extractor

Crates.iocepstrum-extractor
lib.rscepstrum-extractor
version0.1.4
sourcesrc
created_at2024-06-15 22:30:25.250065
updated_at2024-11-20 17:02:15.409769
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,581,668
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 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`
Commit count: 10

cargo fmt