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.
Public Member Functions | Private Attributes | List of all members
AudioResampler Class Reference

#include <audioresampler.h>

+ Collaboration diagram for AudioResampler:

Public Member Functions

 AudioResampler ()
 
 ~AudioResampler ()
 
void setDecimation (uint32_t decimation)
 
uint32_t getDecimation () const
 
void setAudioFilters (int srHigh, int srLow, int fcLow, int fcHigh, float gain=1.0f)
 
bool downSample (qint16 sampleIn, qint16 &sampleOut)
 
bool upSample (qint16 sampleIn, qint16 &sampleOut)
 

Private Attributes

AudioFilter m_audioFilter
 
uint32_t m_decimation
 
uint32_t m_decimationCount
 

Detailed Description

Definition at line 25 of file audioresampler.h.

Constructor & Destructor Documentation

◆ AudioResampler()

AudioResampler::AudioResampler ( )

Definition at line 21 of file audioresampler.cpp.

21  :
22  m_decimation(1),
24 {}
uint32_t m_decimation
uint32_t m_decimationCount

◆ ~AudioResampler()

AudioResampler::~AudioResampler ( )

Definition at line 26 of file audioresampler.cpp.

27 {}

Member Function Documentation

◆ downSample()

bool AudioResampler::downSample ( qint16  sampleIn,
qint16 &  sampleOut 
)

Definition at line 47 of file audioresampler.cpp.

References m_audioFilter, m_decimation, m_decimationCount, and AudioFilter::run().

Referenced by getDecimation(), and FreeDVMod::pullAF().

48 {
49  if (m_decimation == 1)
50  {
51  sampleOut = sampleIn;
52  return true;
53  }
54 
56  {
57  float lpSample = m_audioFilter.run(sampleIn / 32768.0f);
58  sampleOut = lpSample * 32768.0f;
60  return true;
61  }
62  else
63  {
65  return false;
66  }
67 }
uint32_t m_decimation
uint32_t m_decimationCount
AudioFilter m_audioFilter
float run(const float &sample)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDecimation()

uint32_t AudioResampler::getDecimation ( ) const
inline

Definition at line 32 of file audioresampler.h.

References downSample(), m_decimation, setAudioFilters(), and upSample().

Referenced by FreeDVDemod::pushSampleToDV().

32 { return m_decimation; }
uint32_t m_decimation
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAudioFilters()

void AudioResampler::setAudioFilters ( int  srHigh,
int  srLow,
int  fcLow,
int  fcHigh,
float  gain = 1.0f 
)

Definition at line 34 of file audioresampler.cpp.

References m_audioFilter, and AudioFilter::setDecimFilters().

Referenced by FreeDVMod::applyAudioSampleRate(), FreeDVDemod::applyAudioSampleRate(), and getDecimation().

35 {
36  srHigh = (srHigh <= 100 ? 100 : srHigh);
37  srLow = (srLow <= 0 ? 1 : srLow);
38  srLow = srLow > srHigh - 50 ? srHigh - 50 : srLow;
39 
40  fcLow = fcLow < 0 ? 0 : fcLow;
41  fcHigh = fcHigh < 100 ? 100 : fcHigh;
42  fcLow = fcLow > fcHigh - 100 ? fcHigh - 100 : fcLow;
43 
44  m_audioFilter.setDecimFilters(srHigh, srLow, fcHigh, fcLow, gain);
45 }
AudioFilter m_audioFilter
void setDecimFilters(int srHigh, int srLow, float fcHigh, float fcLow, float gain=1.0f)
Definition: audiofilter.cpp:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDecimation()

void AudioResampler::setDecimation ( uint32_t  decimation)

Definition at line 29 of file audioresampler.cpp.

References decimation(), and m_decimation.

Referenced by FreeDVMod::applyAudioSampleRate(), and FreeDVDemod::applyAudioSampleRate().

30 {
31  m_decimation = decimation == 0 ? 1 : decimation;
32 }
int decimation(float Fin, float Fout)
Definition: datvdemod.h:66
uint32_t m_decimation
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ upSample()

bool AudioResampler::upSample ( qint16  sampleIn,
qint16 &  sampleOut 
)

Definition at line 69 of file audioresampler.cpp.

References m_audioFilter, m_decimation, m_decimationCount, and AudioFilter::run().

Referenced by getDecimation(), and FreeDVDemod::pushSampleToDV().

70 {
71  float lpSample;
72 
73  if (m_decimation == 1)
74  {
75  sampleOut = sampleIn;
76  return true;
77  }
78 
80  {
82  lpSample = m_audioFilter.run(sampleIn / 32768.0f);
83  sampleOut = lpSample * 32768.0f;
84  return true;
85  }
86  else
87  {
89  lpSample = m_audioFilter.run(0.0f);
90  sampleOut = lpSample * 32768.0f;
91  return false;
92  }
93 }
uint32_t m_decimation
uint32_t m_decimationCount
AudioFilter m_audioFilter
float run(const float &sample)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_audioFilter

AudioFilter AudioResampler::m_audioFilter
private

Definition at line 38 of file audioresampler.h.

Referenced by downSample(), setAudioFilters(), and upSample().

◆ m_decimation

uint32_t AudioResampler::m_decimation
private

Definition at line 39 of file audioresampler.h.

Referenced by downSample(), getDecimation(), setDecimation(), and upSample().

◆ m_decimationCount

uint32_t AudioResampler::m_decimationCount
private

Definition at line 40 of file audioresampler.h.

Referenced by downSample(), and upSample().


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