LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
lasp_avpowerspectra.h
Go to the documentation of this file.
1#pragma once
2#include "lasp_fft.h"
3#include "lasp_mathtypes.h"
4#include "lasp_timebuffer.h"
5#include "lasp_window.h"
6#include <memory>
7#include <optional>
8
23public:
28
29private:
33 Fft _fft;
34
35 vd _window;
36 d _scale_fac;
37
38public:
45 PowerSpectra(const us nfft, const Window::WindowType w);
46
53 PowerSpectra(const vd &window);
54
68 ccube compute(const dmat &input);
69};
70
77
78 enum class Mode {
79 Averaging = 0, // Averaging all time date
80 Leaking = 1, // Exponential weighting of an "instantaneous cps"
81 Spectrogram = 2 // Instantenous spectrum, no averaging
82 };
83
84 Mode _mode;
85 d _alpha; // Only valid in case of 'Leaking'
86 us n_averages = 0; // Only valid in case of 'Averaging'
87
88 PowerSpectra _ps;
92 ccube _est;
93
97 TimeBuffer _timeBuf;
101 us _overlap_keep;
102
103public:
123 AvPowerSpectra(const us nfft = 2048,
125 const d overlap_percentage = 50.,
126 const d fs_tau = -1);
127
130
135 void reset();
136
150 ccube compute(const dmat &timedata);
151
159 ccube get_est() const;
160
167 us exactOverlapSamples() const { return _ps.nfft - _overlap_keep; }
168};
Estimate cross-power spectra using Welch' method of spectral estimation. The exact amount of overlap ...
ccube get_est() const
Returns the latest estimate of cps (cross-power spectra.
AvPowerSpectra(const AvPowerSpectra &)=delete
ccube compute(const dmat &timedata)
Compute an update of the power spectra based on given time data. Note that the number of channels is ...
us exactOverlapSamples() const
The overlap is rounded to a certain amount of time samples. This function returns that value.
void reset()
Reset to empty state. Clears the time buffer and sets estimator to empty.
AvPowerSpectra & operator=(const AvPowerSpectra &)=delete
Perform forward FFT's on real time data. Computes single-sided spectra, equivalent to Numpy's rfft an...
Definition lasp_fft.h:24
Computes single-sided cross-power spectra for a group of channels. Only a single block of length fft,...
ccube compute(const dmat &input)
Computes the spectra. Data is normalized by the (spectral) power of the window, to compensate for the...
us nfft
The FFT length.
Implementation of a buffer of time samples, where.
arma::Col< d > vd
arma::Mat< d > dmat
arma::Cube< c > ccube
size_t us
We often use boolean values.
Definition lasp_types.h:29