2 releases
0.1.2 | Dec 31, 2024 |
---|---|
0.1.0 | Dec 31, 2024 |
#260 in Audio
236 downloads per month
28KB
495 lines
shady-audio
is the audio backend for the other shady tools.
Its interface let's you easily fetch the frequency presence of the given audio source
by selecting an audio source which implemented the Fetcher
trait.
Example
use std::num::NonZeroUsize;
use shady_audio::{ShadyAudio, fetcher::DummyFetcher, config::ShadyAudioConfig};
fn main() {
let mut audio = {
let fetcher = DummyFetcher::new();
let config = ShadyAudioConfig::default();
ShadyAudio::new(fetcher, config)
};
// Retrieve a spline which you can use, to get any points from the frequancy bands of your audio fetcher.
// `shady-audio` will take care of the rest. Let it be
// - gravity effect
// - smooth transition
// - etc.
let spline = audio.get_spline();
// All relevant points of the spline are stored within the range [0, 1].
// Since we're currently using the [DummyFetcher] our spline equals the function `f(x) = 0`:
assert_eq!(spline.sample(0.0), Some(0.0));
assert_eq!(spline.sample(0.5), Some(0.0));
// actually for some reason, `splines::Spline` returns `None` here and I don't know why ._.
assert_eq!(spline.sample(1.0), None);
// Any other value inside [0, 1] is fine:
assert_eq!(spline.sample(0.123456789), Some(0.0));
}
Dependencies
~4–31MB
~456K SLoC