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

Sound Level Meter implementation that gives a result for each channel. A channel is the result of a filtered signal. More...

#include <lasp_slm.h>

Public Member Functions

 SLM (const d fs, const d Lref, const us downsampling_fac, const d tau, std::unique_ptr< Filter > pre_filter, std::vector< std::unique_ptr< Filter > > bandpass)
 Initialize a Sound Level Meter.
 
 ~SLM ()
 
void reset ()
 Reset state related to samples acquired. All filters reset to zero. Start again from no history.
 
 SLM (const SLM &o)=delete
 
SLMoperator= (const SLM &o)=delete
 
 SLM (SLM &&o)=default
 
dmat run (const vd &input)
 Run the sound level meter on given input data. Return downsampled level data for each filterbank channel.
 
vd Lpeak () const
 Calculates peak levels measured for each filter channel. The peak level is just the highest instantaneous measured power value.
 
vd Leq () const
 Calculates equivalent (time-averaged) levels measured for each filter channel.
 
vd Lmax () const
 Calculates max levels measured for each filter channel. The max value is the maximum time-filtered (Fast / Slow) power level.
 

Static Public Member Functions

static SLM fromBiquads (const d fs, const d Lref, const us downsampling_fac, const d tau, const vd &pre_filter_coefs, const dmat &bandpass_coefs)
 Convenience function to create a Sound Level meter from Biquad filters only.
 
static SLM fromBiquads (const d fs, const d Lref, const us downsampling_fac, const d tau, const dmat &bandpass_coefs)
 Convenience function to create a Sound Level meter from Biquad filters only. No pre-filter, only bandpass.
 
static us suggestedDownSamplingFac (const d fs, const d tw)
 Comput a 'suggested' downsampling factor, i.e. a lower frame rate at which sound level meter values are returned from the computation. This is possible since the signal power is low-pas filtered with a single pole low pass filter. It can remove computational burden, especially for plotting, to have a value > 10.
 

Public Attributes

vd Pm
 Public storage for the mean of the square of the signal.
 
vd Pmax
 Public storage for the maximum signal power, after single pole low-pass filter.
 
vd Ppeak
 Storage for maximum computed signal power so far.
 
us N = 0
 

Detailed Description

Sound Level Meter implementation that gives a result for each channel. A channel is the result of a filtered signal.

Definition at line 17 of file lasp_slm.h.

Constructor & Destructor Documentation

◆ SLM() [1/3]

SLM::SLM ( const d  fs,
const d  Lref,
const us  downsampling_fac,
const d  tau,
std::unique_ptr< Filter pre_filter,
std::vector< std::unique_ptr< Filter > >  bandpass 
)

Initialize a Sound Level Meter.

Counter for the number of time samples counted that came in;

Parameters
fsSampling frequency [Hz]
LrefLevel reference, used to scale to proper decibel units (dB SPL / dBV, etc)
downsampling_facEvery 1/downsampling_fac value is returned from compute()
tauTime consant of level meter
pre_filterThe pre-filter (Typically an A/C frequency weighting filter)
bandpassThe parallel set of bandpass filters.

Definition at line 15 of file lasp_slm.cpp.

◆ ~SLM()

SLM::~SLM ( )

Definition at line 50 of file lasp_slm.cpp.

◆ SLM() [2/3]

SLM::SLM ( const SLM o)
delete

◆ SLM() [3/3]

SLM::SLM ( SLM &&  o)
default

Member Function Documentation

◆ fromBiquads() [1/2]

SLM SLM::fromBiquads ( const d  fs,
const d  Lref,
const us  downsampling_fac,
const d  tau,
const dmat bandpass_coefs 
)
static

Convenience function to create a Sound Level meter from Biquad filters only. No pre-filter, only bandpass.

Parameters
fsSampling frequency [Hz]
LrefLevel reference, used to scale to proper decibel units (dB SPL / dBV, etc)
downsampling_facEvery 1/downsampling_fac value is returned from compute()
tauTime consant of level meter
bandpass_coefsBiquad filter coefficients for bandpass filter. First axis isis the coefficient index, second axis is the filter index.
Returns
Sound Level Meter object

Definition at line 92 of file lasp_slm.cpp.

◆ fromBiquads() [2/2]

SLM SLM::fromBiquads ( const d  fs,
const d  Lref,
const us  downsampling_fac,
const d  tau,
const vd pre_filter_coefs,
const dmat bandpass_coefs 
)
static

Convenience function to create a Sound Level meter from Biquad filters only.

Parameters
fsSampling frequency [Hz]
LrefLevel reference, used to scale to proper decibel units (dB SPL / dBV, etc)
downsampling_facEvery 1/downsampling_fac value is returned from compute()
tauTime consant of level meter
pre_filter_coefsBiquad filter coefficients for pre-filter
bandpass_coefsBiquad filter coeffiecients for bandpass filter
Returns
Sound Level Meter object

Definition at line 83 of file lasp_slm.cpp.

◆ Leq()

vd SLM::Leq ( ) const
inline

Calculates equivalent (time-averaged) levels measured for each filter channel.

Returns
vector of equivalent level values

Definition at line 146 of file lasp_slm.h.

◆ Lmax()

vd SLM::Lmax ( ) const
inline

Calculates max levels measured for each filter channel. The max value is the maximum time-filtered (Fast / Slow) power level.

Returns
vector of max level values

Definition at line 153 of file lasp_slm.h.

◆ Lpeak()

vd SLM::Lpeak ( ) const
inline

Calculates peak levels measured for each filter channel. The peak level is just the highest instantaneous measured power value.

Returns
vector of peak level values

Definition at line 139 of file lasp_slm.h.

◆ operator=()

SLM & SLM::operator= ( const SLM o)
delete

◆ reset()

void SLM::reset ( )

Reset state related to samples acquired. All filters reset to zero. Start again from no history.

Definition at line 193 of file lasp_slm.cpp.

◆ run()

dmat SLM::run ( const vd input)

Run the sound level meter on given input data. Return downsampled level data for each filterbank channel.

Parameters
inputRaw input data
Returns
Filtered level data for each filtered channel.

Definition at line 148 of file lasp_slm.cpp.

◆ suggestedDownSamplingFac()

us SLM::suggestedDownSamplingFac ( const d  fs,
const d  tw 
)
static

Comput a 'suggested' downsampling factor, i.e. a lower frame rate at which sound level meter values are returned from the computation. This is possible since the signal power is low-pas filtered with a single pole low pass filter. It can remove computational burden, especially for plotting, to have a value > 10.

Parameters
fsSampling frequency of signal [Hz]
twTime weighting of SLM low pass filter
Returns
Suggested downsampling factor, no unit. [-]

Definition at line 67 of file lasp_slm.cpp.

Member Data Documentation

◆ N

us SLM::N = 0

Definition at line 55 of file lasp_slm.h.

◆ Pm

vd SLM::Pm

Public storage for the mean of the square of the signal.

Storage for offset point in input arrays

Definition at line 43 of file lasp_slm.h.

◆ Pmax

vd SLM::Pmax

Public storage for the maximum signal power, after single pole low-pass filter.

Definition at line 48 of file lasp_slm.h.

◆ Ppeak

vd SLM::Ppeak

Storage for maximum computed signal power so far.

Public storage for the peak signal power, before single pole low-pass filter.

Definition at line 53 of file lasp_slm.h.


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