From 5a1362667326278dcd4ceca17d47525ddc91236a Mon Sep 17 00:00:00 2001 From: TornaxO7 Date: Tue, 31 Dec 2024 21:52:35 +0100 Subject: [PATCH] shady-audio: Add docs for `ShadyAudio` --- shady-audio/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shady-audio/src/lib.rs b/shady-audio/src/lib.rs index c6e9f7e..d2375cb 100644 --- a/shady-audio/src/lib.rs +++ b/shady-audio/src/lib.rs @@ -81,6 +81,16 @@ pub struct ShadyAudio { } impl ShadyAudio { + /// Create a new instance of this struct by providing the (audio) fetcher and the config. + /// + /// # Example + /// ``` + /// use shady_audio::{ShadyAudio, fetcher::DummyFetcher, config::ShadyAudioConfig}; + /// + /// fn main() { + /// let shady_audio = ShadyAudio::new(DummyFetcher::new(), ShadyAudioConfig::default()); + /// } + /// ``` pub fn new(fetcher: Box, config: ShadyAudioConfig) -> Self { Self { fetcher, @@ -92,6 +102,9 @@ impl ShadyAudio { } } + /// Returns you the latest "frequency spline" which describes the presence of each frequency. + /// The spline basically represents the curve of audio visualizers which are using a bar chart + /// like [`shady-cli`](https://github.com/TornaxO7/shady/tree/main/shady-cli). pub fn get_spline(&mut self) -> &FreqSpline { let magnitudes = match self.timer.ease_time() { Some(ease_time) => self.magnitudes.update_with_ease(ease_time), @@ -108,6 +121,7 @@ impl ShadyAudio { &self.spline } + /// Let's you update the internal config if you'd like to change something. pub fn update_config(&mut self, config: ShadyAudioConfig) { self.timer.set_refresh_time(config.refresh_time); }