Updated comments and added getStreamMetaData() to StreamMgr()

This commit is contained in:
Anne de Jong 2024-07-13 09:43:01 +02:00
parent 622ece7486
commit a905e58023
4 changed files with 49 additions and 15 deletions

View File

@ -42,6 +42,12 @@ static smgr_created: AtomicBool = AtomicBool::new(false);
/// Configure and manage input / output streams. This method is supposed to be a /// Configure and manage input / output streams. This method is supposed to be a
/// SINGLETON. Runtime checks are performed to see whether this is true. /// 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))] #[cfg_attr(feature = "python-bindings", pyclass(unsendable))]
pub struct StreamMgr { pub struct StreamMgr {
// List of available devices // List of available devices
@ -142,6 +148,25 @@ impl StreamMgr {
smgr 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<Arc<StreamMetaData>> {
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. /// Get stream status for given stream type.
pub fn getStatus(&self, t: StreamType) -> StreamStatus { pub fn getStatus(&self, t: StreamType) -> StreamStatus {
match t { match t {

View File

@ -3,9 +3,9 @@
//! This crate contains structures and functions to perform acoustic //! This crate contains structures and functions to perform acoustic
//! measurements, interact with data acquisition devices and apply common //! measurements, interact with data acquisition devices and apply common
//! acoustic analysis operations on them. //! acoustic analysis operations on them.
//! //!
//! You will find the following stuff in this crate: //! You will find the following stuff in this crate:
//! //!
//! - Data acquisition, recording, signal generation //! - Data acquisition, recording, signal generation
//! - Power spectra estimation, transfer function estimation tools. //! - Power spectra estimation, transfer function estimation tools.
//! - Sound Level Meter implementation. //! - Sound Level Meter implementation.
@ -14,14 +14,16 @@
//! //!
//! ## Note to potential users //! ## Note to potential users
//! //!
//! ** This crate is still under heavy development. API changes happen on the //! **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 //! fly. Documentation is not finished. Use with caution and expect things to be
//! broken and buggy. Use at your own risk and responsibility.** //! broken and buggy. Use at your own risk and responsibility.**
//! //!
//! ## Author information //! ## Author information
//! //!
//! The main developer is J.A. de Jong from [ASCEE](https://www.ascee.nl). In //! 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)] #![warn(missing_docs)]
#![allow(non_snake_case)] #![allow(non_snake_case)]

View File

@ -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)] #![allow(non_snake_case)]
use crate::config::*; use crate::config::*;
@ -70,6 +61,17 @@ fn hamming(N: usize) -> Dcol {
/// Window type descriptors. Used for computing the actual window with private /// Window type descriptors. Used for computing the actual window with private
/// functions. See [Window], for the actual window (taper). /// 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)] #[derive(Display, Clone, Debug)]
pub enum WindowType { pub enum WindowType {
/// Von Hann window /// Von Hann window

View File

@ -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 //! # Examples
//! //!
@ -9,9 +10,13 @@
//! let mut wn = Siggen::newWhiteNoise(1); //! let mut wn = Siggen::newWhiteNoise(1);
//! // Set gains for all channels //! // Set gains for all channels
//! wn.setAllGains(0.1); //! wn.setAllGains(0.1);
//! // Unmute all channels
//! wn.setAllMute(false); //! wn.setAllMute(false);
//! // Create a slice where data is stored.
//! let mut sig = [0. ; 1024]; //! let mut sig = [0. ; 1024];
//! // Fill `sig` with the signal data.
//! wn.genSignal(&mut sig); //! wn.genSignal(&mut sig);
//! // Print data.
//! println!("{:?}", &sig); //! println!("{:?}", &sig);
//! //!
//! ``` //! ```