lasprs 0.14.0

Library for Acoustic Signal Processing (Rust edition, with optional Python bindings via pyo3)
//! Data acquisition code. Provides abstract layers around DAQ devices, creating
//! input and output streams and interact with them (record, create signal
//! generators, filter data, show real time sound levels and so on).
//!
//! - Record data in a `Recording`
//! - Interact with DAQ devices:
//!   - Set number of channels, channel names etc.
//!   - Enable / disable IEPE
//!   - Set datatypes etc.
//!
//! Most of the things are done using a [StreamMgr], which is an object to I/O
//! DAQ data, interact with devices etc.

mod api;
mod daqconfig;
mod datatype;
mod deviceinfo;
mod error;
mod qty;
mod streammgr_details;

mod record;
pub use record::*;

mod streamcmd;
mod streamdata;
mod streamerror;
mod streamhandler;
mod streammetadata;
mod streammgr;
mod streammsg;
mod streamstatus;

// Module re-exports
pub use api::DaqApiDescriptor;
pub use daqconfig::{DaqChannel, DaqConfig};
pub use datatype::DataType;
pub use deviceinfo::DeviceInfo;
pub use error::*;
pub use qty::Qty;
pub(crate) use streamcmd::*;
pub(crate) use streamdata::{InStreamData, RawStreamData};
pub use streamerror::StreamError;
pub use streamhandler::StreamHandler;
pub use streammetadata::StreamMetaData;
pub use streammgr::*;
pub use streammsg::{InStreamMsg, PreCaptureBuffer};
pub use streamstatus::StreamStatus;

use crate::*;

/// Stream types that can be available. A duplex stream has two stream
/// directions, see [StreamDirection].
#[cfg_attr(
    feature = "python-bindings",
    gen_stub_pyclass_enum,
    pyclass(eq, eq_int, from_py_object)
)]
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum StreamType {
    /// Input-only stream
    Input = 0,
    /// Output-only stream
    Output = 1,
    /// Input and output at the same time
    Duplex = 2,
}

/// Stream direction. A single stream can have either input, output or both
/// input and output. The direction of the stream is defined with this enum.
#[cfg_attr(
    feature = "python-bindings",
    gen_stub_pyclass_enum,
    pyclass(eq, eq_int, from_py_object)
)]
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum StreamDirection {
    /// Input data
    Input = 0,
    /// Output data
    Output = 1,
}

#[cfg(feature = "python-bindings")]
/// Add Python classes from stream manager
pub fn add_py_classses<'py>(m: &Bound<'py, PyModule>) -> PyResult<()> {
    use daqconfig::DaqChannel;

    use crate::daq::daqconfig::CouplingMode;

    m.add_class::<DeviceInfo>()?;

    m.add_class::<StreamMgr>()?;
    m.add_class::<StreamMgrError>()?;
    m.add_class::<PyStreamMgrError>()?;
    m.add_class::<StreamMgrError>()?;

    m.add_class::<DaqApiDescriptor>()?;
    m.add_class::<DataType>()?;
    m.add_class::<Qty>()?;
    m.add_class::<CouplingMode>()?;
    m.add_class::<StreamType>()?;
    m.add_class::<StreamDirection>()?;
    m.add_class::<StreamStatus>()?;
    m.add_class::<StreamMetaData>()?;
    m.add_class::<StreamError>()?;
    m.add_class::<DaqChannel>()?;
    m.add_class::<DaqConfig>()?;
    m.add_class::<RecordSettings>()?;
    m.add_class::<RecordStatus>()?;
    m.add_class::<Recording>()?;

    Ok(())
}