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 | Protected Member Functions | Protected Attributes | List of all members
IntHalfbandFilterEOF< HBFilterOrder > Class Template Reference

#include <inthalfbandfiltereof.h>

Public Member Functions

 IntHalfbandFilterEOF ()
 
bool workDecimateCenter (float *x, float *y)
 
void myDecimate (float x1, float y1, float *x2, float *y2)
 
void myInterpolateZeroStuffing (float *x1, float *y1, float *x2, float *y2)
 
void myInterpolate (float *x1, float *y1, float *x2, float *y2)
 
void myInterpolateInf (float *x1, float *y1, float *x2, float *y2, float *x3, float *y3, float *x4, float *y4)
 
void myInterpolateSup (float *x1, float *y1, float *x2, float *y2, float *x3, float *y3, float *x4, float *y4)
 

Protected Member Functions

void storeSample (float x, float y)
 
void advancePointer ()
 
void doFIR (float *x, float *y)
 
void doInterpolateFIR (float *x, float *y)
 

Protected Attributes

float m_even [2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
 
float m_odd [2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
 
float m_samples [HBFIRFilterTraits< HBFilterOrder >::hbOrder][2]
 
int m_ptr
 
int m_size
 
int m_state
 

Detailed Description

template<uint32_t HBFilterOrder>
class IntHalfbandFilterEOF< HBFilterOrder >

Definition at line 33 of file inthalfbandfiltereof.h.

Constructor & Destructor Documentation

◆ IntHalfbandFilterEOF()

template<uint32_t HBFilterOrder>
IntHalfbandFilterEOF< HBFilterOrder >::IntHalfbandFilterEOF ( )

Definition at line 237 of file inthalfbandfiltereof.h.

238 {
240 
241  for (int i = 0; i < 2*m_size; i++)
242  {
243  m_even[0][i] = 0.0f;
244  m_even[1][i] = 0.0f;
245  m_odd[0][i] = 0.0f;
246  m_odd[1][i] = 0.0f;
247  m_samples[i][0] = 0.0f;
248  m_samples[i][1] = 0.0f;
249  }
250 
251  m_ptr = 0;
252  m_state = 0;
253 }
float m_odd[2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
float m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder][2]
float m_even[2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
int32_t i
Definition: decimators.h:244

Member Function Documentation

◆ advancePointer()

template<uint32_t HBFilterOrder>
void IntHalfbandFilterEOF< HBFilterOrder >::advancePointer ( )
inlineprotected

◆ doFIR()

template<uint32_t HBFilterOrder>
void IntHalfbandFilterEOF< HBFilterOrder >::doFIR ( float *  x,
float *  y 
)
inlineprotected

Definition at line 174 of file inthalfbandfiltereof.h.

Referenced by IntHalfbandFilterEOF< DECIMATORS_IF_FILTER_ORDER >::myDecimate(), IntHalfbandFilterEOF< DECIMATORS_IF_FILTER_ORDER >::myInterpolateZeroStuffing(), and IntHalfbandFilterEOF< DECIMATORS_IF_FILTER_ORDER >::workDecimateCenter().

175  {
176  float iAcc = 0;
177  float qAcc = 0;
178 
179  int a = m_ptr/2 + m_size; // tip pointer
180  int b = m_ptr/2 + 1; // tail pointer
181 
182  for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
183  {
184  if ((m_ptr % 2) == 0)
185  {
186  iAcc += (m_even[0][a] + m_even[0][b]) * HBFIRFilterTraits<HBFilterOrder>::hbCoeffsF[i];
187  qAcc += (m_even[1][a] + m_even[1][b]) * HBFIRFilterTraits<HBFilterOrder>::hbCoeffsF[i];
188  }
189  else
190  {
191  iAcc += (m_odd[0][a] + m_odd[0][b]) * HBFIRFilterTraits<HBFilterOrder>::hbCoeffsF[i];
192  qAcc += (m_odd[1][a] + m_odd[1][b]) * HBFIRFilterTraits<HBFilterOrder>::hbCoeffsF[i];
193  }
194 
195  a -= 1;
196  b += 1;
197  }
198 
199  if ((m_ptr % 2) == 0)
200  {
201  iAcc += m_odd[0][m_ptr/2 + m_size/2] * 0.5f;
202  qAcc += m_odd[1][m_ptr/2 + m_size/2] * 0.5f;
203  }
204  else
205  {
206  iAcc += m_even[0][m_ptr/2 + m_size/2 + 1] * 0.5f;
207  qAcc += m_even[1][m_ptr/2 + m_size/2 + 1] * 0.5f;
208  }
209 
210  *x = iAcc; // HB_SHIFT incorrect do not loose the gained bit
211  *y = qAcc;
212  }
float m_odd[2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
float m_even[2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ doInterpolateFIR()

template<uint32_t HBFilterOrder>
void IntHalfbandFilterEOF< HBFilterOrder >::doInterpolateFIR ( float *  x,
float *  y 
)
inlineprotected

Definition at line 214 of file inthalfbandfiltereof.h.

Referenced by IntHalfbandFilterEOF< DECIMATORS_IF_FILTER_ORDER >::myInterpolate().

215  {
216  qint32 iAcc = 0;
217  qint32 qAcc = 0;
218 
219  qint16 a = m_ptr;
220  qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1;
221 
222  // go through samples in buffer
223  for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
224  {
227  a++;
228  b--;
229  }
230 
231  *x = iAcc * SDR_RX_SCALED;
232  *y = qAcc * SDR_RX_SCALED;
233  }
float m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder][2]
int32_t i
Definition: decimators.h:244
#define SDR_RX_SCALED
Definition: dsptypes.h:34
+ Here is the caller graph for this function:

◆ myDecimate()

template<uint32_t HBFilterOrder>
void IntHalfbandFilterEOF< HBFilterOrder >::myDecimate ( float  x1,
float  y1,
float *  x2,
float *  y2 
)
inline

◆ myInterpolate()

template<uint32_t HBFilterOrder>
void IntHalfbandFilterEOF< HBFilterOrder >::myInterpolate ( float *  x1,
float *  y1,
float *  x2,
float *  y2 
)
inline

Optimized upsampler by 2 not calculating FIR with inserted null samples

Definition at line 87 of file inthalfbandfiltereof.h.

Referenced by IntHalfbandFilterEOF< DECIMATORS_IF_FILTER_ORDER >::myInterpolateInf(), and IntHalfbandFilterEOF< DECIMATORS_IF_FILTER_ORDER >::myInterpolateSup().

88  {
89  // insert sample into ring double buffer
90  m_samples[m_ptr][0] = *x1;
91  m_samples[m_ptr][1] = *y1;
94 
95  // advance pointer
97  m_ptr++;
98  } else {
99  m_ptr = 0;
100  }
101 
102  // first output sample calculated with the middle peak
105 
106  // second sample calculated with the filter
107  doInterpolateFIR(x2, y2);
108  }
float m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder][2]
void doInterpolateFIR(float *x, float *y)
+ Here is the caller graph for this function:

◆ myInterpolateInf()

template<uint32_t HBFilterOrder>
void IntHalfbandFilterEOF< HBFilterOrder >::myInterpolateInf ( float *  x1,
float *  y1,
float *  x2,
float *  y2,
float *  x3,
float *  y3,
float *  x4,
float *  y4 
)
inline

Definition at line 110 of file inthalfbandfiltereof.h.

111  {
112  myInterpolate(x1, y1, x2, y2);
113  myInterpolate(x3, y3, x4, y4);
114  // rotation
115  qint32 x;
116  x = *x1;
117  *x1 = *y1;
118  *y1 = -x;
119  *x2 = -*x2;
120  *y2 = -*y2;
121  x = *x3;
122  *x3 = -*y3;
123  *y3 = x;
124  }
void myInterpolate(float *x1, float *y1, float *x2, float *y2)

◆ myInterpolateSup()

template<uint32_t HBFilterOrder>
void IntHalfbandFilterEOF< HBFilterOrder >::myInterpolateSup ( float *  x1,
float *  y1,
float *  x2,
float *  y2,
float *  x3,
float *  y3,
float *  x4,
float *  y4 
)
inline

Definition at line 126 of file inthalfbandfiltereof.h.

127  {
128  myInterpolate(x1, y1, x2, y2);
129  myInterpolate(x3, y3, x4, y4);
130  // rotation
131  qint32 x;
132  x = *x1;
133  *x1 = -*y1;
134  *y1 = x;
135  *x2 = -*x2;
136  *y2 = -*y2;
137  x = *x3;
138  *x3 = *y3;
139  *y3 = -x;
140  }
void myInterpolate(float *x1, float *y1, float *x2, float *y2)

◆ myInterpolateZeroStuffing()

template<uint32_t HBFilterOrder>
void IntHalfbandFilterEOF< HBFilterOrder >::myInterpolateZeroStuffing ( float *  x1,
float *  y1,
float *  x2,
float *  y2 
)
inline

Simple zero stuffing and filter

Definition at line 75 of file inthalfbandfiltereof.h.

76  {
77  storeSample(*x1, *y1);
78  doFIR(x1, y1);
80 
81  storeSample(0, 0);
82  doFIR(x2, y2);
84  }
void storeSample(float x, float y)
void doFIR(float *x, float *y)

◆ storeSample()

template<uint32_t HBFilterOrder>
void IntHalfbandFilterEOF< HBFilterOrder >::storeSample ( float  x,
float  y 
)
inlineprotected

Definition at line 151 of file inthalfbandfiltereof.h.

Referenced by IntHalfbandFilterEOF< DECIMATORS_IF_FILTER_ORDER >::myDecimate(), IntHalfbandFilterEOF< DECIMATORS_IF_FILTER_ORDER >::myInterpolateZeroStuffing(), and IntHalfbandFilterEOF< DECIMATORS_IF_FILTER_ORDER >::workDecimateCenter().

152  {
153  if ((m_ptr % 2) == 0)
154  {
155  m_even[0][m_ptr/2] = x;
156  m_even[1][m_ptr/2] = y;
157  m_even[0][m_ptr/2 + m_size] = x;
158  m_even[1][m_ptr/2 + m_size] = y;
159  }
160  else
161  {
162  m_odd[0][m_ptr/2] = x;
163  m_odd[1][m_ptr/2] = y;
164  m_odd[0][m_ptr/2 + m_size] = x;
165  m_odd[1][m_ptr/2 + m_size] = y;
166  }
167  }
float m_odd[2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
float m_even[2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
+ Here is the caller graph for this function:

◆ workDecimateCenter()

template<uint32_t HBFilterOrder>
bool IntHalfbandFilterEOF< HBFilterOrder >::workDecimateCenter ( float *  x,
float *  y 
)
inline

Definition at line 37 of file inthalfbandfiltereof.h.

38  {
39  // insert sample into ring-buffer
40  storeSample(*x, *y);
41 
42  switch(m_state)
43  {
44  case 0:
45  // advance write-pointer
47  // next state
48  m_state = 1;
49  // tell caller we don't have a new sample
50  return false;
51 
52  default:
53  // save result
54  doFIR(x, y);
55  // advance write-pointer
57  // next state
58  m_state = 0;
59  // tell caller we have a new sample
60  return true;
61  }
62  }
void storeSample(float x, float y)
void doFIR(float *x, float *y)

Member Data Documentation

◆ m_even

template<uint32_t HBFilterOrder>
float IntHalfbandFilterEOF< HBFilterOrder >::m_even[2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
protected

◆ m_odd

template<uint32_t HBFilterOrder>
float IntHalfbandFilterEOF< HBFilterOrder >::m_odd[2][HBFIRFilterTraits< HBFilterOrder >::hbOrder]
protected

◆ m_ptr

template<uint32_t HBFilterOrder>
int IntHalfbandFilterEOF< HBFilterOrder >::m_ptr
protected

◆ m_samples

template<uint32_t HBFilterOrder>
float IntHalfbandFilterEOF< HBFilterOrder >::m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder][2]
protected

◆ m_size

template<uint32_t HBFilterOrder>
int IntHalfbandFilterEOF< HBFilterOrder >::m_size
protected

◆ m_state

template<uint32_t HBFilterOrder>
int IntHalfbandFilterEOF< HBFilterOrder >::m_state
protected

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