From a905e5802363f9bffa80a6a72033761ab3f19625 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Sat, 13 Jul 2024 09:43:01 +0200 Subject: [PATCH] Updated comments and added getStreamMetaData() to StreamMgr() --- src/daq/streammgr.rs | 25 +++++++++++++++++++++++++ src/lib.rs | 12 +++++++----- src/ps/window.rs | 20 +++++++++++--------- src/siggen.rs | 7 ++++++- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/daq/streammgr.rs b/src/daq/streammgr.rs index 2d3652b..a781d63 100644 --- a/src/daq/streammgr.rs +++ b/src/daq/streammgr.rs @@ -42,6 +42,12 @@ static smgr_created: AtomicBool = AtomicBool::new(false); /// Configure and manage input / output streams. This method is supposed to be a /// SINGLETON. Runtime checks are performed to see whether this is true. /// +/// A stream manager provides the interaction layer for interacting with audio / +/// data streams. +/// +/// * See [Recording] for an example of starting a recording on an input stream. +/// * See [Siggen] for an example of playing a signal to an output stream. +/// #[cfg_attr(feature = "python-bindings", pyclass(unsendable))] pub struct StreamMgr { // List of available devices @@ -142,6 +148,25 @@ impl StreamMgr { smgr } + /// Returns the metadata for a given stream, when the stream type (see + /// [StreamType]) is alive, i.e. (StreamMgr::getStatus) gives a 'Running'. + /// + pub fn getStreamMetaData(&self, t: StreamType) -> Option> { + match t { + StreamType::Input | StreamType::Duplex => { + if let Some(s) = &self.input_stream { + return Some(s.stream.metadata()); + } + } + StreamType::Output => { + if let Some(s) = &self.output_stream { + return Some(s.stream.metadata()); + } + } + } + None + } + /// Get stream status for given stream type. pub fn getStatus(&self, t: StreamType) -> StreamStatus { match t { diff --git a/src/lib.rs b/src/lib.rs index e9b2252..4092b98 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,9 +3,9 @@ //! This crate contains structures and functions to perform acoustic //! measurements, interact with data acquisition devices and apply common //! acoustic analysis operations on them. -//! +//! //! You will find the following stuff in this crate: -//! +//! //! - Data acquisition, recording, signal generation //! - Power spectra estimation, transfer function estimation tools. //! - Sound Level Meter implementation. @@ -14,14 +14,16 @@ //! //! ## Note to potential users //! -//! ** This crate is still under heavy development. API changes happen on the -//! fly. Documentation is not finished. Use with caution but except things to be +//! **This crate is still under heavy development. API changes happen on the +//! fly. Documentation is not finished. Use with caution and expect things to be //! broken and buggy. Use at your own risk and responsibility.** //! //! ## Author information //! //! The main developer is J.A. de Jong from [ASCEE](https://www.ascee.nl). In -//! case of bug reports, please file them to info@ascee.nl. +//! case of bug reports, please file them to [info@ascee.nl](info@ascee.nl). +//! +//! If you have particular interest in this library, please also contact us. //! #![warn(missing_docs)] #![allow(non_snake_case)] diff --git a/src/ps/window.rs b/src/ps/window.rs index ff62082..7e0ce78 100644 --- a/src/ps/window.rs +++ b/src/ps/window.rs @@ -1,12 +1,3 @@ -//! Window functions designed for Welch' method. Implementations are given for -//! the 5 classical window functions: -//! -//! * Rect - rectangular -//! * Hann - Von Hann window (sometimes wrongly called "Hanning") -//! * Bartlett -//! * Hamming -//! * Blackman -//! #![allow(non_snake_case)] use crate::config::*; @@ -70,6 +61,17 @@ fn hamming(N: usize) -> Dcol { /// Window type descriptors. Used for computing the actual window with private /// functions. See [Window], for the actual window (taper). +/// +/// Window functions designed for Welch' method. Implementations are given for +/// the 5 classical window functions: +/// +/// * Hann - Von Hann window (sometimes wrongly called "Hanning") +/// * Rect - rectangular +/// * Bartlett +/// * Hamming +/// * Blackman +/// +/// The [WindowType::default] is [WindowType::Hann]. #[derive(Display, Clone, Debug)] pub enum WindowType { /// Von Hann window diff --git a/src/siggen.rs b/src/siggen.rs index bef9ce1..f6c4d81 100644 --- a/src/siggen.rs +++ b/src/siggen.rs @@ -1,4 +1,5 @@ -//! This module provide signal generators. +//! This module provide signal generators. The import struct defined here is +//! [Siggen], which has several creation methods. //! //! # Examples //! @@ -9,9 +10,13 @@ //! let mut wn = Siggen::newWhiteNoise(1); //! // Set gains for all channels //! wn.setAllGains(0.1); +//! // Unmute all channels //! wn.setAllMute(false); +//! // Create a slice where data is stored. //! let mut sig = [0. ; 1024]; +//! // Fill `sig` with the signal data. //! wn.genSignal(&mut sig); +//! // Print data. //! println!("{:?}", &sig); //! //! ```