Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SpecPowerCalculation Class Reference

SpecPowerCalculation is a simple spectral power level meter. More...

#include <SpecPowerMeter.h>

Collaboration diagram for SpecPowerCalculation:
[legend]

Public Member Functions

 SpecPowerCalculation (size_t sigLen)
 
 ~SpecPowerCalculation ()
 
float CalcPower (float *sig, float fc, float bw)
 

Private Member Functions

float CalcBinPower (float *sig_f_r, float *sig_f_i, int loBin, int hiBin)
 
int Freq2Bin (float fc)
 

Private Attributes

const size_t mSigLen
 
Floats mSigI
 
Floats mSigFR
 
Floats mSigFI
 

Detailed Description

SpecPowerCalculation is a simple spectral power level meter.

SpecPowerCalculation operates in the Fourier domain and allows power level measurements in subbands or in the entire signal band.

Definition at line 17 of file SpecPowerMeter.h.

Constructor & Destructor Documentation

◆ SpecPowerCalculation()

SpecPowerCalculation::SpecPowerCalculation ( size_t  sigLen)

Definition at line 27 of file SpecPowerMeter.cpp.

28 : mSigLen(sigLen)
29 , mSigI{ sigLen, true }
30 , mSigFR{ sigLen }
31 , mSigFI{ sigLen }
32{
33}
const size_t mSigLen

◆ ~SpecPowerCalculation()

SpecPowerCalculation::~SpecPowerCalculation ( )

Definition at line 35 of file SpecPowerMeter.cpp.

36{
37}

Member Function Documentation

◆ CalcBinPower()

float SpecPowerCalculation::CalcBinPower ( float *  sig_f_r,
float *  sig_f_i,
int  loBin,
int  hiBin 
)
private

Definition at line 61 of file SpecPowerMeter.cpp.

62{
63 float pwr = 0.0f;
64
65 for (int n = loBin; n < hiBin; n++)
66 {
67 pwr += ((sig_f_r[n]*sig_f_r[n])+(sig_f_i[n]*sig_f_i[n]));
68 }
69
70 return pwr;
71}

Referenced by CalcPower().

Here is the caller graph for this function:

◆ CalcPower()

float SpecPowerCalculation::CalcPower ( float *  sig,
float  fc,
float  bw 
)

Definition at line 39 of file SpecPowerMeter.cpp.

40{
41 float pwr;
42 int loBin, hiBin;
43
44 // Given the bandwidth bw, get the boundary bin numbers
45 loBin = Freq2Bin(fc - (bw / 2.0f));
46 hiBin = Freq2Bin(fc + (bw / 2.0f));
47 if (loBin == hiBin)
48 {
49 hiBin = loBin + 1;
50 }
51
52 // Calc the FFT
53 FFT(mSigLen, 0, sig, mSigI.get(), mSigFR.get(), mSigFI.get());
54
55 // Calc the in-band power
56 pwr = CalcBinPower(mSigFR.get(), mSigFI.get(), loBin, hiBin);
57
58 return pwr;
59}
void FFT(size_t NumSamples, bool InverseTransform, const float *RealIn, const float *ImagIn, float *RealOut, float *ImagOut)
Definition: FFT.cpp:129
float CalcBinPower(float *sig_f_r, float *sig_f_i, int loBin, int hiBin)
int Freq2Bin(float fc)

References CalcBinPower(), FFT(), Freq2Bin(), mSigFI, mSigFR, mSigI, and mSigLen.

Referenced by FormatClassifier::Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Freq2Bin()

int SpecPowerCalculation::Freq2Bin ( float  fc)
private

Definition at line 73 of file SpecPowerMeter.cpp.

74{
75 int bin;
76
77 // There is no round() in (older) MSVSs ...
78 bin = floor((double)fc * mSigLen);
79 bin %= (int)mSigLen;
80
81 return bin;
82}

References mSigLen.

Referenced by CalcPower().

Here is the caller graph for this function:

Member Data Documentation

◆ mSigFI

Floats SpecPowerCalculation::mSigFI
private

Definition at line 23 of file SpecPowerMeter.h.

Referenced by CalcPower().

◆ mSigFR

Floats SpecPowerCalculation::mSigFR
private

Definition at line 22 of file SpecPowerMeter.h.

Referenced by CalcPower().

◆ mSigI

Floats SpecPowerCalculation::mSigI
private

Definition at line 21 of file SpecPowerMeter.h.

Referenced by CalcPower().

◆ mSigLen

const size_t SpecPowerCalculation::mSigLen
private

Definition at line 19 of file SpecPowerMeter.h.

Referenced by CalcPower(), and Freq2Bin().


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