#shady #non-zero #dummy-fetcher

shady-audio

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

27 releases (13 major breaking)

new 14.0.0 May 9, 2025
13.0.0 Apr 7, 2025
12.0.0 Apr 6, 2025
11.0.0 Apr 6, 2025
0.1.2 Dec 31, 2024

#391 in Audio

Download history 211/week @ 2025-02-05 147/week @ 2025-02-12 1040/week @ 2025-02-19 107/week @ 2025-02-26 468/week @ 2025-03-05 79/week @ 2025-03-12 4/week @ 2025-03-19 123/week @ 2025-03-26 884/week @ 2025-04-02 94/week @ 2025-04-09 26/week @ 2025-04-16 4/week @ 2025-04-23 13/week @ 2025-04-30

234 downloads per month
Used in 2 crates

GPL-3.0-or-later

53KB
1K SLoC

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::NonZero;
use shady_audio::{SampleProcessor, BarProcessor, BarProcessorConfig, fetcher::DummyFetcher};

let mut sample_processor = SampleProcessor::new(DummyFetcher::new());

let mut bar_processor = BarProcessor::new(
    &sample_processor,
    BarProcessorConfig {
        amount_bars: NonZero::new(20).unwrap(),
        ..Default::default()
    }
);
let mut bar_processor2 = BarProcessor::new(
    &sample_processor,
    BarProcessorConfig {
        amount_bars: NonZero::new(10).unwrap(),
        ..Default::default()
    }
);

loop {
    // the sample processor needs to compute the new samples only once
    // for both bar processors (to reduce computation)
    sample_processor.process_next_samples();

    let bars = bar_processor.process_bars(&sample_processor);
    let bars2 = bar_processor2.process_bars(&sample_processor);

    assert_eq!(bars.len(), 20);
    assert_eq!(bars2.len(), 10);

    break;
}

Dependencies

~7–35MB
~513K SLoC