LASP 1.0
Library for Acoustic Signal Processing
|
Estimate cross-power spectra using Welch' method of spectral estimation. The exact amount of overlap in Welch' method is rounded up to a certain amount of samples. More...
#include <lasp_avpowerspectra.h>
Public Member Functions | |
AvPowerSpectra (const us nfft=2048, const Window::WindowType w=Window::WindowType::Hann, const d overlap_percentage=50., const d fs_tau=-1) | |
Initalize averaged power spectra computer. If a time constant is given > 0, it is used in a kind of exponential weighting. | |
AvPowerSpectra (const AvPowerSpectra &)=delete | |
AvPowerSpectra & | operator= (const AvPowerSpectra &)=delete |
void | reset () |
Reset to empty state. Clears the time buffer and sets estimator to empty. | |
ccube | compute (const dmat &timedata) |
Compute an update of the power spectra based on given time data. Note that the number of channels is determined from the first time this function is called. If a later call has an incompatible number of channels, a runtime error is thrown. | |
ccube | get_est () const |
Returns the latest estimate of cps (cross-power spectra. | |
us | exactOverlapSamples () const |
The overlap is rounded to a certain amount of time samples. This function returns that value. | |
Estimate cross-power spectra using Welch' method of spectral estimation. The exact amount of overlap in Welch' method is rounded up to a certain amount of samples.
Definition at line 76 of file lasp_avpowerspectra.h.
AvPowerSpectra::AvPowerSpectra | ( | const us | nfft = 2048 , |
const Window::WindowType | w = Window::WindowType::Hann , |
||
const d | overlap_percentage = 50. , |
||
const d | fs_tau = -1 |
||
) |
Initalize averaged power spectra computer. If a time constant is given > 0, it is used in a kind of exponential weighting.
nfft | The fft length |
w | The window type. |
overlap_percentage | A number 0 < overlap_percentage <= 100. It determines the amount of overlap used in Welch' method. A typical value is 50 %, i.e. 50. |
fs_tau | Value should either be < 0, indicating that the estimate is averages over all time data. For a value = 0 the instantaneous power spectrum is returned, which can be interpreted as the spectrogram. For a value > 0 a exponential forgetting is used, where the value is used as the time constant such that the decay follows approximately the trend exp(-n/fs_tau), where n is the sample number in the power spectra. To choose 'fast' time weighting, set time_constant to the value of fs*0.125, where fs denotes the sampling frequency. |
Definition at line 55 of file lasp_avpowerspectra.cpp.
|
delete |
Compute an update of the power spectra based on given time data. Note that the number of channels is determined from the first time this function is called. If a later call has an incompatible number of channels, a runtime error is thrown.
timedata |
Return a copy of current estimator in case we have done one update. Othewise, we return an empty ccube.
Definition at line 88 of file lasp_avpowerspectra.cpp.
|
inline |
The overlap is rounded to a certain amount of time samples. This function returns that value.
Definition at line 167 of file lasp_avpowerspectra.h.
ccube AvPowerSpectra::get_est | ( | ) | const |
Returns the latest estimate of cps (cross-power spectra.
Definition at line 134 of file lasp_avpowerspectra.cpp.
|
delete |
void AvPowerSpectra::reset | ( | ) |
Reset to empty state. Clears the time buffer and sets estimator to empty.
Definition at line 81 of file lasp_avpowerspectra.cpp.