5#include "debugtrace.hpp"
10using Lck = std::scoped_lock<std::mutex>;
15 const d overlap_percentage,
const d time_constant)
17 _ps(nfft, w, overlap_percentage, time_constant) {
19 if (freqWeightingFilter !=
nullptr) {
20 _filterPrototype = freqWeightingFilter->
clone();
35 const us nchannels = fltdata.n_cols;
36 if(nchannels != _sens.size()) {
37 cerr <<
"**** Error: sensitivity size does not match! *****" << endl;
40 fltdata.each_row() %= _sens.as_row();
42 if (_filterPrototype) {
45 if (nchannels > _freqWeightingFilters.size()) {
46 while (nchannels > _freqWeightingFilters.size()) {
47 _freqWeightingFilters.emplace_back(_filterPrototype->clone());
50 for (
auto &filter : _freqWeightingFilters) {
56 #pragma omp parallel for
57 for (
us i = 0; i < nchannels; i++) {
58 vd col = fltdata.col(i);
59 _freqWeightingFilters.at(i)->filter(col);
71 for (
auto &filter : _freqWeightingFilters) {
78 _sens[i] = ch.sensitivity;
ccube get_est() const
Returns the latest estimate of cps (cross-power spectra.
ccube compute(const dmat &timedata)
Compute an update of the power spectra based on given time data. Note that the number of channels is ...
void reset()
Reset to empty state. Clears the time buffer and sets estimator to empty.
std::vector< DaqChannel > enabledInChannels(const bool include_monitor=true) const
Return list of enabled input channels.
Data coming from / going to DAQ. Non-interleaved format, which means data in buffer is ordered by cha...
arma::Mat< d > toFloat() const
Convert samples to floating point values and return a nframes x nchannels array of floats....
Base cass for all DAQ (Data Acquisition) interfaces. A DAQ can be a custom device,...
us neninchannels(bool include_monitorchannels=true) const
Returns the number of enabled input channels.
Filter used to pre-filter a double-precision floating point data stream.
virtual std::unique_ptr< Filter > clone() const =0
Clone a filter, to generate a copy.
ccube getCurrentValue() const
Get the latest estimate of the power spectra.
void inCallback(const DaqData &d)
Implements the work to to when new DaqData arrives.
RtAps(SmgrHandle mgr, const Filter *freqWeightingFilter, const us nfft=2048, const Window::WindowType w=Window::WindowType::Hann, const d overlap_percentage=50., const d time_constant=-1)
Initialize RtAps.
void startThread()
This method should be called from the derived class' constructor, to start the thread and data is inc...
void stopThread()
This method SHOULD be called from all classes that derive on ThreadedInDataHandler....
A bit of curiously recurring template pattern, to connect the specific handlers and connect the prope...
std::scoped_lock< std::mutex > Lck
std::shared_ptr< StreamMgr > SmgrHandle
std::scoped_lock< std::mutex > lck
size_t us
We often use boolean values.