Implemented only storage of signal range in PPM struct as well
This commit is contained in:
parent
26515b9ee0
commit
c5a96c6fc1
@ -13,7 +13,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
/// When the level reaches ALMOST_CLIPPED_REL_AMP in amplitude, w.r.t. to the
|
||||
/// full scale, we mark a channel as almost clipped.
|
||||
const ALMOST_CLIPPED_REL_AMP: Flt = 0.98;
|
||||
pub const ALMOST_CLIPPED_REL_AMP: Flt = 0.98;
|
||||
|
||||
/// If clipping occured, this is the time it keeps saying 'signal is clipped'
|
||||
const CLIP_INDICATOR_WAIT_S: Duration = Duration::from_secs(2);
|
||||
@ -66,7 +66,7 @@ impl PPM {
|
||||
|
||||
rayon::spawn(move || {
|
||||
let mut slms: Vec<SLM> = vec![];
|
||||
let mut streammeta: Option<Arc<StreamMetaData>> = None;
|
||||
let mut ranges: Vec<(Flt, Flt)> = vec![];
|
||||
|
||||
let resetall = |slms: &mut Vec<SLM>| {
|
||||
let mut status = status.lock();
|
||||
@ -82,13 +82,11 @@ impl PPM {
|
||||
InStreamMsg::InStreamData(d) => {
|
||||
let mut status = status.lock();
|
||||
let floatdata = d.getFloatData();
|
||||
let meta = streammeta.as_ref().expect("Stream metadata not available");
|
||||
let channels = &meta.channelInfo;
|
||||
|
||||
'channel: for (chno, ((slm, ppmstatus), ch)) in slms
|
||||
'channel: for (chno, ((slm, ppmstatus), range)) in slms
|
||||
.iter_mut()
|
||||
.zip(status.iter_mut())
|
||||
.zip(channels)
|
||||
.zip(ranges.iter())
|
||||
.enumerate()
|
||||
{
|
||||
let chdata = floatdata.slice(s![.., chno]);
|
||||
@ -116,13 +114,13 @@ impl PPM {
|
||||
continue 'channel;
|
||||
}
|
||||
|
||||
let clip = min_val <= ALMOST_CLIPPED_REL_AMP * ch.range.0
|
||||
|| max_val >= ALMOST_CLIPPED_REL_AMP * ch.range.1;
|
||||
let clip = min_val <= ALMOST_CLIPPED_REL_AMP * range.0
|
||||
|| max_val >= ALMOST_CLIPPED_REL_AMP * range.1;
|
||||
|
||||
let abs_range = if ch.range.0.abs() > ch.range.1.abs() {
|
||||
ch.range.0.abs()
|
||||
let abs_range = if range.0.abs() > range.1.abs() {
|
||||
range.0.abs()
|
||||
} else {
|
||||
ch.range.1.abs()
|
||||
range.1.abs()
|
||||
};
|
||||
let high_level_threshold =
|
||||
level(abs_range) + LEVEL_THRESHOLD_FOR_HIGH_LEVEL;
|
||||
@ -175,7 +173,7 @@ impl PPM {
|
||||
clip_time: None,
|
||||
});
|
||||
});
|
||||
streammeta = Some(meta);
|
||||
ranges = meta.channelInfo.iter().map(|ch| ch.range).collect();
|
||||
}
|
||||
InStreamMsg::StreamStopped => {}
|
||||
}
|
||||
|
@ -13,9 +13,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
/// If signal is below / above the range times the value below, we indicate that
|
||||
/// the signal has clipped.
|
||||
const CLIP_REL_LIMIT: Flt = 0.99;
|
||||
use super::ppm::ALMOST_CLIPPED_REL_AMP;
|
||||
|
||||
/// Very simple clip detector. Used to detect cliping in a recording. Stores one
|
||||
/// clip value if just something happened between time of new and moment of drop().
|
||||
@ -70,8 +68,8 @@ impl SimpleClipDetector {
|
||||
// Compare minima and maxima against clip limits
|
||||
maxs.iter().zip(mins.iter()).zip(ranges.iter()).for_each(
|
||||
|((max, min), range)| {
|
||||
let min_for_clip = CLIP_REL_LIMIT * range.0;
|
||||
let max_for_clip = CLIP_REL_LIMIT * range.1;
|
||||
let min_for_clip = ALMOST_CLIPPED_REL_AMP * range.0;
|
||||
let max_for_clip = ALMOST_CLIPPED_REL_AMP * range.1;
|
||||
if *max >= max_for_clip {
|
||||
clipstate.store(true, Relaxed);
|
||||
// We do not have to do anything anymore. The signal
|
||||
|
Loading…
Reference in New Issue
Block a user