use crate::{config::*, daq::StreamMgr};
mod clipstate;
mod ppm;
mod ppmdropspeed;
pub mod ppmchannel;
pub use clipstate::ClipState;
pub use ppm::PPM;
pub use ppmchannel::PPMChannelStatus;
pub use ppmdropspeed::PPMDropSpeed;
use std::{sync::Arc, time::Duration};
pub const LEVEL_THRESHOLD_FOR_LOW_LEVEL: Flt = -60.;
pub const LEVEL_THRESHOLD_FOR_HIGH_LEVEL: Flt = -10.;
pub const ALMOST_CLIPPED_REL_AMP: Flt = 0.98;
pub const CLIP_INDICATOR_WAIT_S: Flt = 2.;
pub const PEAK_LEVEL_HOLD_TIME_S: Flt = 1.;
#[cfg(feature = "python-bindings")]
#[cfg_attr(feature = "python-bindings", pyclass(name = "PPM"))]
pub struct PPMWrapper {
PPM: Arc<PPM>,
}
#[cfg(feature = "python-bindings")]
#[cfg_attr(feature = "python-bindings", pymethods)]
impl PPMWrapper {
#[staticmethod]
#[pyo3(name = "newMonitor")]
fn newMonitor_py(smgr: &mut StreamMgr, dropSpeed: PPMDropSpeed) -> Self {
Self {
PPM: PPM::newMonitor(smgr, dropSpeed),
}
}
#[staticmethod]
#[pyo3(name = "newInput")]
fn newInput_py(smgr: &mut StreamMgr, dropSpeed: PPMDropSpeed) -> Self {
Self {
PPM: PPM::newInput(smgr, dropSpeed),
}
}
#[pyo3(name = "getState")]
fn getState_py<'py>(
&self,
py: Python<'py>,
) -> (
Bound<'py, PyArray1<Flt>>,
Bound<'py, PyArray1<Flt>>,
Vec<ClipState>,
) {
let (levels, peak_levels, clips) = self.PPM.getState();
let levels = levels.to_pyarray(py);
let peak_levels = peak_levels.to_pyarray(py);
(levels, peak_levels, clips)
}
}