LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
AvPowerSpectra Class Reference

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
 
AvPowerSpectraoperator= (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ AvPowerSpectra() [1/2]

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.

Parameters
nfftThe fft length
wThe window type.
overlap_percentageA number 0 < overlap_percentage <= 100. It determines the amount of overlap used in Welch' method. A typical value is 50 %, i.e. 50.
fs_tauValue 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.

◆ AvPowerSpectra() [2/2]

AvPowerSpectra::AvPowerSpectra ( const AvPowerSpectra )
delete

Member Function Documentation

◆ compute()

ccube AvPowerSpectra::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.

Parameters
timedata
Returns
a copy of the latest estimate of the power spectra. an update is only given if the amount of new time data is enough to compute a new estimate. if no new estimate is available, it returns an empty ccube. Note that the latest available estimate can be obtained using get_est().

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.

◆ exactOverlapSamples()

us AvPowerSpectra::exactOverlapSamples ( ) const
inline

The overlap is rounded to a certain amount of time samples. This function returns that value.

Returns
The amount of samples in overlapping.

Definition at line 167 of file lasp_avpowerspectra.h.

◆ get_est()

ccube AvPowerSpectra::get_est ( ) const

Returns the latest estimate of cps (cross-power spectra.

Returns
a copy of the latest estimate of the power spectra. an update is only given if the amount of new time data is enough to compute a new estimate. If no estimate is available, it returns an empty ccube.

Definition at line 134 of file lasp_avpowerspectra.cpp.

◆ operator=()

AvPowerSpectra & AvPowerSpectra::operator= ( const AvPowerSpectra )
delete

◆ reset()

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.


The documentation for this class was generated from the following files: