| Crates.io | cepstrum-extractor |
| lib.rs | cepstrum-extractor |
| version | 0.2.0 |
| created_at | 2024-06-15 22:30:25.250065+00 |
| updated_at | 2025-04-15 13:37:47.960825+00 |
| description | An easy-to-use crate to compute the cepstrum of a signal. |
| homepage | |
| repository | https://github.com/Skilvingr/rust-cepstrum-extractor |
| max_upload_size | |
| id | 1273165 |
| size | 8,594,430 |
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.
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].
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.
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.
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.
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`