#fetcher #retrieve #frequency #fetch #source #shady

shady-audio

A high level library build upon cpal to retrieve audio for visualisation

11 stable releases (3 major)

new 4.0.2 Feb 21, 2025
3.2.1 Feb 21, 2025
2.0.3 Feb 11, 2025
0.1.2 Dec 31, 2024

#231 in Audio

Download history 231/week @ 2024-12-31 9/week @ 2025-01-07 1/week @ 2025-01-14 123/week @ 2025-02-04 318/week @ 2025-02-11

441 downloads per month
Used in 2 crates

GPL-3.0-or-later

30KB
523 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};

let mut audio = {
    // A fetcher feeds new samples to `ShadyAudio` which processes it
    let fetcher = DummyFetcher::new();

    // configure the behaviour of `ShadyAudio`
    let config = ShadyAudioConfig {
        amount_bars: NonZeroUsize::new(10).unwrap(),
        ..Default::default()
    };

    ShadyAudio::new(fetcher, config).unwrap()
};

// just retrieve the bars.
// ShadyAudio takes care of the rest:
//   - fetching new samples from the fetcher
//   - normalize the values within the range [0, 1]
//   - etc.
assert_eq!(audio.get_bars().len(), 10);

// change the amount of bars you'd like to have
audio.set_bars(NonZeroUsize::new(20).unwrap());
assert_eq!(audio.get_bars().len(), 20);

Dependencies

~4–35MB
~468K SLoC