SDRAngel
4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
|
#include <audiofilter.h>
Public Member Functions | |
AudioFilter () | |
~AudioFilter () | |
void | useHP (bool useHP) |
bool | usesHP () const |
void | setDecimFilters (int srHigh, int srLow, float fcHigh, float fcLow, float gain=1.0f) |
float | run (const float &sample) |
float | runHP (const float &sample) |
float | runLP (const float &sample) |
Private Member Functions | |
void | calculate2 (bool highPass, double fc, float *a, float *b, float fgain) |
void | cheby (bool highPass, double fc, float pr, int np, double *a, double *b, float fgain) |
void | cheby_sub (bool highPass, double fc, float pr, int np, int stage, double &a0, double &a1, double &a2, double &b1, double &b2) |
Private Attributes | |
IIRFilter< float, 2 > | m_filterLP |
IIRFilter< float, 2 > | m_filterHP |
bool | m_useHP |
float | m_lpva [3] |
float | m_lpvb [3] |
float | m_hpva [3] |
float | m_hpvb [3] |
Static Private Attributes | |
static const float | m_lpa [3] = {1.0, 1.392667E+00, -5.474446E-01} |
static const float | m_lpb [3] = {3.869430E-02, 7.738860E-02, 3.869430E-02} |
static const float | m_hpa [3] = {1.000000e+00, 1.667871e+00, -7.156964e-01} |
static const float | m_hpb [3] = {8.459039e-01, -1.691760e+00, 8.459039e-01} |
By default this is a 2 pole lowpass Chebyshev (recursive) filter at fc=0.075 using coefficients found in table 20-1 of http://www.analog.com/media/en/technical-documentation/dsp-book/dsp_book_Ch20.pdf
At the interpolated sampling frequency of 48 kHz the -3 dB corner is at 48 * .075 = 3.6 kHz which is perfect for voice
a0= 3.869430E-02 a1= 7.738860E-02 b1= 1.392667E+00 a2= 3.869430E-02 b2= -5.474446E-01
given x[n] is the new input sample and y[n] the returned output sample:
y[n] = a0*x[n] + a1*x[n] + a2*x[n] + b1*y[n-1] + b2*y[n-2]
This one works directly with floats
It can be generalized using the program found in tables 20-4 and 20-5 of the same document. This form is used as a decimation filter and can be set with the setDecimFilters method
Definition at line 44 of file audiofilter.h.
AudioFilter::AudioFilter | ( | ) |
Definition at line 32 of file audiofilter.cpp.
AudioFilter::~AudioFilter | ( | ) |
Definition at line 38 of file audiofilter.cpp.
|
private |
Definition at line 54 of file audiofilter.cpp.
Referenced by setDecimFilters().
|
private |
Definition at line 83 of file audiofilter.cpp.
References b1, b2, cheby_sub(), and i.
Referenced by calculate2().
|
private |
float AudioFilter::run | ( | const float & | sample | ) |
Definition at line 196 of file audiofilter.cpp.
References m_filterHP, m_filterLP, m_useHP, and IIRFilter< Type, Order >::run().
Referenced by AudioResampler::downSample(), AudioResampler::upSample(), and AudioNetSink::write().
float AudioFilter::runHP | ( | const float & | sample | ) |
Definition at line 201 of file audiofilter.cpp.
References m_filterHP, and IIRFilter< Type, Order >::run().
float AudioFilter::runLP | ( | const float & | sample | ) |
Definition at line 206 of file audiofilter.cpp.
References m_filterLP, and IIRFilter< Type, Order >::run().
Referenced by AudioNetSink::write().
void AudioFilter::setDecimFilters | ( | int | srHigh, |
int | srLow, | ||
float | fcHigh, | ||
float | fcLow, | ||
float | gain = 1.0f |
||
) |
Definition at line 42 of file audiofilter.cpp.
References calculate2(), m_filterHP, m_filterLP, m_hpva, m_hpvb, m_lpva, m_lpvb, and IIRFilter< Type, Order >::setCoeffs().
Referenced by AudioResampler::setAudioFilters(), and AudioNetSink::setDecimationFilters().
|
inline |
Definition at line 49 of file audiofilter.h.
References useHP().
Referenced by useHP().
|
inline |
Definition at line 50 of file audiofilter.h.
|
private |
Definition at line 63 of file audiofilter.h.
Referenced by run(), runHP(), and setDecimFilters().
|
private |
Definition at line 62 of file audiofilter.h.
Referenced by run(), runLP(), and setDecimFilters().
|
staticprivate |
Definition at line 71 of file audiofilter.h.
|
staticprivate |
Definition at line 72 of file audiofilter.h.
|
private |
Definition at line 67 of file audiofilter.h.
Referenced by setDecimFilters().
|
private |
Definition at line 68 of file audiofilter.h.
Referenced by setDecimFilters().
|
staticprivate |
Definition at line 69 of file audiofilter.h.
|
staticprivate |
Definition at line 70 of file audiofilter.h.
|
private |
Definition at line 65 of file audiofilter.h.
Referenced by setDecimFilters().
|
private |
Definition at line 66 of file audiofilter.h.
Referenced by setDecimFilters().
|
private |
Definition at line 64 of file audiofilter.h.
Referenced by run().