ridgeline

Crates.ioridgeline
lib.rsridgeline
version0.2.0
sourcesrc
created_at2021-09-29 22:06:19.248965
updated_at2021-10-01 19:56:14.747063
descriptionSimple frequency spectrum analysis
homepage
repositoryhttps://github.com/kaikalii/ridgeline
max_upload_size
id458403
size41,473
Kai Schmidt (kaikalii)

documentation

https://docs.rs/ridgeline

README

Description

Ridgeline is a crate for simplifying frequency spectrum analysis of streamed signals.

For more information, check out the documentation.

Usage

The SignalSource trait defines behavior for a signal. SystemAudio is a SignalSource implementation that streams audio samples from a system audio device.

Spectrometer is an iterator that wraps a SignalSource and yields Spectrums.

Spectrum contains frequency data for a signal at a single point in time. The aplitude of a given frequency can be queried with Spectrum::amplitude.

Example: Get the dominant frequency

use std::{thread::sleep, time::Duration};

use ridgeline::*;

// Stream audio from the default input device
let audio_input = SystemAudio::from_default_device().unwrap();

// Create a `Spectrometer` from the audio input stream with 5000 FFT buckets
// The actual FFT buffer uses SIZE * 2 buckets, but only the lower half is usable
let spectrometer = audio_input.analyze::<5000>();

// Print the frequency with the highest amplitude
for spectrum in spectrometer {
    println!("{} Hz", spectrum.dominant());
    sleep(Duration::from_millis(10));
}
Commit count: 23

cargo fmt