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 | Static Private Member Functions | Private Attributes | List of all members
FreqLockComplex Class Reference

#include <freqlockcomplex.h>

Public Member Functions

 FreqLockComplex ()
 
 ~FreqLockComplex ()
 
void reset ()
 
void setSampleRate (unsigned int sampleRate)
 
void feed (float re, float im)
 
const std::complex< float > & getComplex () const
 
float getReal () const
 
float getImag () const
 
float getFreq () const
 

Static Private Member Functions

static float normalizeAngle (float angle)
 

Private Attributes

float m_a0
 
float m_a1
 
std::complex< float > m_y
 
float m_yRe
 
float m_yIm
 
float m_freq
 
float m_phi
 
float m_phiX0
 
float m_phiX1
 
float m_y1
 

Detailed Description

General purpose Phase-locked loop using complex analytic signal input.

Definition at line 31 of file freqlockcomplex.h.

Constructor & Destructor Documentation

◆ FreqLockComplex()

FreqLockComplex::FreqLockComplex ( )

Definition at line 28 of file freqlockcomplex.cpp.

28  :
29  m_a0(0.998),
30  m_a1(0.002),
31  m_y(1.0, 0.0),
32  m_yRe(1.0),
33  m_yIm(0.0),
34  m_freq(0.0),
35  m_phi(0.0),
36  m_phiX0(0.0),
37  m_phiX1(0.0),
38  m_y1(0.0f)
39 {
40 }
std::complex< float > m_y

◆ ~FreqLockComplex()

FreqLockComplex::~FreqLockComplex ( )

Definition at line 42 of file freqlockcomplex.cpp.

43 {
44 }

Member Function Documentation

◆ feed()

void FreqLockComplex::feed ( float  re,
float  im 
)

Feed PLL with a new signa sample

Definition at line 66 of file freqlockcomplex.cpp.

References arg(), cos(), m_a0, m_a1, m_freq, m_phi, m_phiX0, m_phiX1, m_y, m_y1, m_yIm, m_yRe, normalizeAngle(), and sin().

Referenced by ChannelAnalyzer::processOneSample(), and FreqTracker::processOneSample().

67 {
68  m_yRe = cos(m_phi);
69  m_yIm = sin(m_phi);
70  m_y.real(m_yRe);
71  m_y.imag(m_yIm);
72  std::complex<float> x(re, im);
73  m_phiX0 = std::arg(x);
74 
75  float eF = normalizeAngle(m_phiX0 - m_phiX1);
76  float fHat = m_a1*eF + m_a0*m_y1;
77  m_y1 = fHat;
78 
79  m_freq = fHat; // correct instantaneous frequency
80  m_phi += fHat; // advance phase with instantaneous frequency
81  m_phiX1 = m_phiX0;
82 }
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
std::complex< float > m_y
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
static float normalizeAngle(float angle)
Fixed< IntType, IntBits > sin(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2265
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComplex()

const std::complex<float>& FreqLockComplex::getComplex ( ) const
inline

Definition at line 41 of file freqlockcomplex.h.

Referenced by ChannelAnalyzer::processOneSample().

41 { return m_y; }
std::complex< float > m_y
+ Here is the caller graph for this function:

◆ getFreq()

float FreqLockComplex::getFreq ( ) const
inline

Definition at line 44 of file freqlockcomplex.h.

Referenced by FreqTracker::getFrequency(), and ChannelAnalyzer::getPllFrequency().

44 { return m_freq; }
+ Here is the caller graph for this function:

◆ getImag()

float FreqLockComplex::getImag ( ) const
inline

Definition at line 43 of file freqlockcomplex.h.

43 { return m_yIm; }

◆ getReal()

float FreqLockComplex::getReal ( ) const
inline

Definition at line 42 of file freqlockcomplex.h.

42 { return m_yRe; }

◆ normalizeAngle()

float FreqLockComplex::normalizeAngle ( float  angle)
staticprivate

Normalize angle in radians into the [-pi,+pi] region

Definition at line 84 of file freqlockcomplex.cpp.

References M_PI.

Referenced by feed().

85 {
86  while (angle <= -M_PI) {
87  angle += 2.0*M_PI;
88  }
89  while (angle > M_PI) {
90  angle -= 2.0*M_PI;
91  }
92  return angle;
93 }
#define M_PI
Definition: rdsdemod.cpp:27
+ Here is the caller graph for this function:

◆ reset()

void FreqLockComplex::reset ( )

Definition at line 46 of file freqlockcomplex.cpp.

References m_freq, m_phi, m_phiX0, m_phiX1, m_y, m_y1, m_yIm, and m_yRe.

Referenced by ChannelAnalyzer::applySettings(), FreqTracker::applySettings(), and setSampleRate().

47 {
48  m_y.real(1.0);
49  m_y.imag(0.0);
50  m_yRe = 1.0f;
51  m_yIm = 0.0f;
52  m_freq = 0.0f;
53  m_phi = 0.0f;
54  m_phiX0 = 0.0f;
55  m_phiX1 = 0.0f;
56  m_y1 = 0.0f;
57 }
std::complex< float > m_y
+ Here is the caller graph for this function:

◆ setSampleRate()

void FreqLockComplex::setSampleRate ( unsigned int  sampleRate)

Definition at line 59 of file freqlockcomplex.cpp.

References m_a0, m_a1, and reset().

Referenced by ChannelAnalyzer::applyChannelSettings(), ChannelAnalyzer::applySettings(), and FreqTracker::configureChannelizer().

60 {
61  m_a1 = 10.0f / sampleRate; // 1 - alpha
62  m_a0 = 1.0f - m_a1; // alpha
63  reset();
64 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_a0

float FreqLockComplex::m_a0
private

Definition at line 50 of file freqlockcomplex.h.

Referenced by feed(), and setSampleRate().

◆ m_a1

float FreqLockComplex::m_a1
private

Definition at line 51 of file freqlockcomplex.h.

Referenced by feed(), and setSampleRate().

◆ m_freq

float FreqLockComplex::m_freq
private

Definition at line 55 of file freqlockcomplex.h.

Referenced by feed(), and reset().

◆ m_phi

float FreqLockComplex::m_phi
private

Definition at line 56 of file freqlockcomplex.h.

Referenced by feed(), and reset().

◆ m_phiX0

float FreqLockComplex::m_phiX0
private

Definition at line 57 of file freqlockcomplex.h.

Referenced by feed(), and reset().

◆ m_phiX1

float FreqLockComplex::m_phiX1
private

Definition at line 58 of file freqlockcomplex.h.

Referenced by feed(), and reset().

◆ m_y

std::complex<float> FreqLockComplex::m_y
private

Definition at line 52 of file freqlockcomplex.h.

Referenced by feed(), and reset().

◆ m_y1

float FreqLockComplex::m_y1
private

Definition at line 59 of file freqlockcomplex.h.

Referenced by feed(), and reset().

◆ m_yIm

float FreqLockComplex::m_yIm
private

Definition at line 54 of file freqlockcomplex.h.

Referenced by feed(), and reset().

◆ m_yRe

float FreqLockComplex::m_yRe
private

Definition at line 53 of file freqlockcomplex.h.

Referenced by feed(), and reset().


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