2023-01-27 13:56:46 +00:00
|
|
|
// lasp_clip.h
|
|
|
|
//
|
2023-02-01 21:41:54 +00:00
|
|
|
// Author: J.A. de Jong, C.R.D. Jansen - ASCEE
|
2023-01-27 13:56:46 +00:00
|
|
|
//
|
2023-02-01 21:41:54 +00:00
|
|
|
// Description: Clip handler
|
2023-01-27 13:56:46 +00:00
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include "lasp_filter.h"
|
|
|
|
#include "lasp_mathtypes.h"
|
|
|
|
#include "lasp_threadedindatahandler.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \addtogroup dsp
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* \addtogroup rt
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clipping detector (Clip). Detects when a signal overdrives the input
|
|
|
|
* */
|
2023-06-09 08:43:04 +00:00
|
|
|
class ClipHandler: public ThreadedInDataHandler<ClipHandler> {
|
2023-01-27 13:56:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Assuming full scale of a signal is +/- 1.0. If a value is found
|
|
|
|
*/
|
|
|
|
static inline const d clip_point = 0.98;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief How long it takes in [s] after a clip event has happened, that we
|
|
|
|
* are actually still in 'clip' mode.
|
|
|
|
*/
|
|
|
|
static inline const d clip_indication_time = 2.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Inverse of block sampling frequency [s]: (framesPerBlock/fs)
|
|
|
|
*/
|
|
|
|
d _dt;
|
|
|
|
|
|
|
|
|
|
|
|
mutable std::mutex _mtx;
|
|
|
|
/**
|
|
|
|
* @brief How long ago the last clip has happened. Negative in case no clip
|
|
|
|
* has happened.
|
|
|
|
*/
|
|
|
|
vd _clip_time;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Storage for maximum values
|
|
|
|
*/
|
|
|
|
vd _max_range;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Constructs Clipping indicator
|
|
|
|
*
|
|
|
|
* @param mgr Stream Mgr to operate on
|
|
|
|
*/
|
2023-06-07 19:49:07 +00:00
|
|
|
ClipHandler(SmgrHandle mgr);
|
2023-01-27 13:56:46 +00:00
|
|
|
~ClipHandler();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the current values of the clip handler. Returns a vector of of True's.
|
|
|
|
*
|
|
|
|
* @return clipping indication
|
|
|
|
*/
|
|
|
|
arma::uvec getCurrentValue() const;
|
|
|
|
|
2023-06-09 08:43:04 +00:00
|
|
|
void inCallback(const DaqData& );
|
|
|
|
void reset(const Daq*);
|
2023-01-27 13:56:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
/** @} */
|