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
IntHalfbandFilter< AccuType, HBFilterOrder > Class Template Reference

#include <inthalfbandfilter.h>

Public Member Functions

 IntHalfbandFilter ()
 
bool workDecimateCenter (Sample *sample)
 
bool workInterpolateCenterZeroStuffing (Sample *sampleIn, Sample *SampleOut)
 
bool workInterpolateCenter (Sample *sampleIn, Sample *SampleOut)
 
bool workDecimateLowerHalf (Sample *sample)
 
bool workInterpolateLowerHalfZeroStuffing (Sample *sampleIn, Sample *sampleOut)
 
bool workInterpolateLowerHalf (Sample *sampleIn, Sample *sampleOut)
 
bool workDecimateUpperHalf (Sample *sample)
 
bool workInterpolateUpperHalfZeroStuffing (Sample *sampleIn, Sample *sampleOut)
 
bool workInterpolateUpperHalf (Sample *sampleIn, Sample *sampleOut)
 
void myDecimate (const Sample *sample1, Sample *sample2)
 
void myDecimate (qint32 x1, qint32 y1, qint32 *x2, qint32 *y2)
 
void myInterpolateZeroStuffing (Sample *sample1, Sample *sample2)
 
void myInterpolateZeroStuffing (qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2)
 
void myInterpolate (qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2)
 
void myInterpolateInf (qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2, qint32 *x3, qint32 *y3, qint32 *x4, qint32 *y4)
 
void myInterpolateSup (qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2, qint32 *x3, qint32 *y3, qint32 *x4, qint32 *y4)
 

Protected Member Functions

void doFIR (Sample *sample)
 
void doInterpolateFIR (Sample *sample)
 
void doInterpolateFIR (qint32 *x, qint32 *y)
 
void doFIR (qint32 *x, qint32 *y)
 

Protected Attributes

AccuType m_samples [HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]
 
qint16 m_ptr
 
int m_state
 

Detailed Description

template<typename AccuType, uint32_t HBFilterOrder>
class IntHalfbandFilter< AccuType, HBFilterOrder >

Definition at line 28 of file inthalfbandfilter.h.

Constructor & Destructor Documentation

◆ IntHalfbandFilter()

template<typename AccuType, uint32_t HBFilterOrder>
IntHalfbandFilter< AccuType, HBFilterOrder >::IntHalfbandFilter ( )
inline

Definition at line 30 of file inthalfbandfilter.h.

30  :
31  m_ptr(0),
32  m_state(0)
33  {
34  for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder + 1; i++)
35  {
36  m_samples[i][0] = 0;
37  m_samples[i][1] = 0;
38  }
39  }
int32_t i
Definition: decimators.h:244
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

Member Function Documentation

◆ doFIR() [1/2]

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::doFIR ( Sample sample)
inlineprotected

Definition at line 788 of file inthalfbandfilter.h.

789  {
790  // init read-pointer
791  int a = HBFIRFilterTraits<HBFilterOrder>::hbMod[m_ptr + 2 + 1]; // 0 + 1
792  int b = HBFIRFilterTraits<HBFilterOrder>::hbMod[m_ptr + 2 - 2]; //-1 - 1
793 
794  // go through samples in buffer
795  AccuType iAcc = 0;
796  AccuType qAcc = 0;
797 
798  for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
799  {
800  // do multiply-accumulate
801  //qint32 iTmp = m_samples[a][0] + m_samples[b][0]; // Valgrind optim
802  //qint32 qTmp = m_samples[a][1] + m_samples[b][1]; // Valgrind optim
805 
806  // update read-pointer
809  }
810 
812 
813  iAcc += ((qint32)m_samples[a][0] + 1) << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
814  qAcc += ((qint32)m_samples[a][1] + 1) << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
815 
818  }
int32_t i
Definition: decimators.h:244
void setImag(FixReal v)
Definition: dsptypes.h:59
void setReal(FixReal v)
Definition: dsptypes.h:58
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ doFIR() [2/2]

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::doFIR ( qint32 *  x,
qint32 *  y 
)
inlineprotected

Definition at line 862 of file inthalfbandfilter.h.

863  {
864  // Coefficents. This is a sinc function:
865  // Half of the half of coefficients are stored because:
866  // - half of the coefficients are 0
867  // - there is a symmertry around the central 0.5 coefficient (not stored either)
868  // There are actually order+1 coefficients
869 
870  // init read-pointer
871  int a = HBFIRFilterTraits<HBFilterOrder>::hbMod[m_ptr + 2 + 1]; // 0 + 1
872  int b = HBFIRFilterTraits<HBFilterOrder>::hbMod[m_ptr + 2 - 2]; //-1 - 1
873 
874  // go through samples in buffer
875  AccuType iAcc = 0;
876  AccuType qAcc = 0;
877 
878  for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
879  {
880  // do multiply-accumulate
881  //qint32 iTmp = m_samples[a][0] + m_samples[b][0]; // Valgrind optim
882  //qint32 qTmp = m_samples[a][1] + m_samples[b][1]; // Valgrind optim
885 
886  // update read-pointer
889  }
890 
892 
893  iAcc += ((qint32)m_samples[a][0] + 1) << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
894  qAcc += ((qint32)m_samples[a][1] + 1) << (HBFIRFilterTraits<HBFilterOrder>::hbShift - 1);
895 
896  *x = iAcc >> (HBFIRFilterTraits<HBFilterOrder>::hbShift -1); // HB_SHIFT incorrect do not loose the gained bit
898  }
int32_t i
Definition: decimators.h:244
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ doInterpolateFIR() [1/2]

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::doInterpolateFIR ( Sample sample)
inlineprotected

Definition at line 820 of file inthalfbandfilter.h.

821  {
822  qint16 a = m_ptr;
823  qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1;
824 
825  // go through samples in buffer
826  AccuType iAcc = 0;
827  AccuType qAcc = 0;
828 
829  for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
830  {
833  a++;
834  b--;
835  }
836 
839  }
int32_t i
Definition: decimators.h:244
void setImag(FixReal v)
Definition: dsptypes.h:59
void setReal(FixReal v)
Definition: dsptypes.h:58
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ doInterpolateFIR() [2/2]

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::doInterpolateFIR ( qint32 *  x,
qint32 *  y 
)
inlineprotected

Definition at line 841 of file inthalfbandfilter.h.

842  {
843  qint16 a = m_ptr;
844  qint16 b = m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder / 2) - 1;
845 
846  // go through samples in buffer
847  AccuType iAcc = 0;
848  AccuType qAcc = 0;
849 
850  for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 4; i++)
851  {
854  a++;
855  b--;
856  }
857 
860  }
int32_t i
Definition: decimators.h:244
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ myDecimate() [1/2]

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::myDecimate ( const Sample sample1,
Sample sample2 
)
inline

Definition at line 663 of file inthalfbandfilter.h.

664  {
665  m_samples[m_ptr][0] = sample1->real();
666  m_samples[m_ptr][1] = sample1->imag();
668 
669  m_samples[m_ptr][0] = sample2->real();
670  m_samples[m_ptr][1] = sample2->imag();
671 
672  doFIR(sample2);
673 
675  }
void doFIR(Sample *sample)
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ myDecimate() [2/2]

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::myDecimate ( qint32  x1,
qint32  y1,
qint32 *  x2,
qint32 *  y2 
)
inline

Definition at line 677 of file inthalfbandfilter.h.

678  {
679  m_samples[m_ptr][0] = x1;
680  m_samples[m_ptr][1] = y1;
682 
683  m_samples[m_ptr][0] = *x2;
684  m_samples[m_ptr][1] = *y2;
685 
686  doFIR(x2, y2);
687 
689  }
void doFIR(Sample *sample)
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ myInterpolate()

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::myInterpolate ( qint32 *  x1,
qint32 *  y1,
qint32 *  x2,
qint32 *  y2 
)
inline

Optimized upsampler by 2 not calculating FIR with inserted null samples

Definition at line 728 of file inthalfbandfilter.h.

729  {
730  // insert sample into ring double buffer
731  m_samples[m_ptr][0] = *x1;
732  m_samples[m_ptr][1] = *y1;
735 
736  // advance pointer
738  m_ptr++;
739  } else {
740  m_ptr = 0;
741  }
742 
743  // first output sample calculated with the middle peak
746 
747  // second sample calculated with the filter
748  doInterpolateFIR(x2, y2);
749  }
void doInterpolateFIR(Sample *sample)
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ myInterpolateInf()

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::myInterpolateInf ( qint32 *  x1,
qint32 *  y1,
qint32 *  x2,
qint32 *  y2,
qint32 *  x3,
qint32 *  y3,
qint32 *  x4,
qint32 *  y4 
)
inline

Definition at line 751 of file inthalfbandfilter.h.

752  {
753  myInterpolate(x1, y1, x2, y2);
754  myInterpolate(x3, y3, x4, y4);
755  // rotation
756  qint32 x;
757  x = *x1;
758  *x1 = *y1;
759  *y1 = -x;
760  *x2 = -*x2;
761  *y2 = -*y2;
762  x = *x3;
763  *x3 = -*y3;
764  *y3 = x;
765  }
void myInterpolate(qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2)

◆ myInterpolateSup()

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::myInterpolateSup ( qint32 *  x1,
qint32 *  y1,
qint32 *  x2,
qint32 *  y2,
qint32 *  x3,
qint32 *  y3,
qint32 *  x4,
qint32 *  y4 
)
inline

Definition at line 767 of file inthalfbandfilter.h.

768  {
769  myInterpolate(x1, y1, x2, y2);
770  myInterpolate(x3, y3, x4, y4);
771  // rotation
772  qint32 x;
773  x = *x1;
774  *x1 = -*y1;
775  *y1 = x;
776  *x2 = -*x2;
777  *y2 = -*y2;
778  x = *x3;
779  *x3 = *y3;
780  *y3 = -x;
781  }
void myInterpolate(qint32 *x1, qint32 *y1, qint32 *x2, qint32 *y2)

◆ myInterpolateZeroStuffing() [1/2]

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::myInterpolateZeroStuffing ( Sample sample1,
Sample sample2 
)
inline

Simple zero stuffing and filter

Definition at line 692 of file inthalfbandfilter.h.

693  {
694  m_samples[m_ptr][0] = sample1->real();
695  m_samples[m_ptr][1] = sample1->imag();
696 
697  doFIR(sample1);
698 
700 
701  m_samples[m_ptr][0] = 0;
702  m_samples[m_ptr][1] = 0;
703 
704  doFIR(sample2);
705 
707  }
void doFIR(Sample *sample)
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ myInterpolateZeroStuffing() [2/2]

template<typename AccuType, uint32_t HBFilterOrder>
void IntHalfbandFilter< AccuType, HBFilterOrder >::myInterpolateZeroStuffing ( qint32 *  x1,
qint32 *  y1,
qint32 *  x2,
qint32 *  y2 
)
inline

Simple zero stuffing and filter

Definition at line 710 of file inthalfbandfilter.h.

711  {
712  m_samples[m_ptr][0] = *x1;
713  m_samples[m_ptr][1] = *y1;
714 
715  doFIR(x1, y1);
716 
718 
719  m_samples[m_ptr][0] = 0;
720  m_samples[m_ptr][1] = 0;
721 
722  doFIR(x2, y2);
723 
725  }
void doFIR(Sample *sample)
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ workDecimateCenter()

template<typename AccuType, uint32_t HBFilterOrder>
bool IntHalfbandFilter< AccuType, HBFilterOrder >::workDecimateCenter ( Sample sample)
inline

Definition at line 42 of file inthalfbandfilter.h.

43  {
44  // insert sample into ring-buffer
45  m_samples[m_ptr][0] = sample->real();
46  m_samples[m_ptr][1] = sample->imag();
47 
48  switch(m_state)
49  {
50  case 0:
51  // advance write-pointer
53 
54  // next state
55  m_state = 1;
56 
57  // tell caller we don't have a new sample
58  return false;
59 
60  default:
61  // save result
62  doFIR(sample);
63 
64  // advance write-pointer
66 
67  // next state
68  m_state = 0;
69 
70  // tell caller we have a new sample
71  return true;
72  }
73  }
void doFIR(Sample *sample)
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ workDecimateLowerHalf()

template<typename AccuType, uint32_t HBFilterOrder>
bool IntHalfbandFilter< AccuType, HBFilterOrder >::workDecimateLowerHalf ( Sample sample)
inline

Definition at line 222 of file inthalfbandfilter.h.

223  {
224  switch(m_state)
225  {
226  case 0:
227  // insert sample into ring-buffer
228  m_samples[m_ptr][0] = -sample->imag();
229  m_samples[m_ptr][1] = sample->real();
230 
231  // advance write-pointer
233 
234  // next state
235  m_state = 1;
236 
237  // tell caller we don't have a new sample
238  return false;
239 
240  case 1:
241  // insert sample into ring-buffer
242  m_samples[m_ptr][0] = -sample->real();
243  m_samples[m_ptr][1] = -sample->imag();
244 
245  // save result
246  doFIR(sample);
247 
248  // advance write-pointer
250 
251  // next state
252  m_state = 2;
253 
254  // tell caller we have a new sample
255  return true;
256 
257  case 2:
258  // insert sample into ring-buffer
259  m_samples[m_ptr][0] = sample->imag();
260  m_samples[m_ptr][1] = -sample->real();
261 
262  // advance write-pointer
264 
265  // next state
266  m_state = 3;
267 
268  // tell caller we don't have a new sample
269  return false;
270 
271  default:
272  // insert sample into ring-buffer
273  m_samples[m_ptr][0] = sample->real();
274  m_samples[m_ptr][1] = sample->imag();
275 
276  // save result
277  doFIR(sample);
278 
279  // advance write-pointer
281 
282  // next state
283  m_state = 0;
284 
285  // tell caller we have a new sample
286  return true;
287  }
288  }
void doFIR(Sample *sample)
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ workDecimateUpperHalf()

template<typename AccuType, uint32_t HBFilterOrder>
bool IntHalfbandFilter< AccuType, HBFilterOrder >::workDecimateUpperHalf ( Sample sample)
inline

Definition at line 443 of file inthalfbandfilter.h.

444  {
445  switch(m_state)
446  {
447  case 0:
448  // insert sample into ring-buffer
449  m_samples[m_ptr][0] = sample->imag();
450  m_samples[m_ptr][1] = -sample->real();
451 
452  // advance write-pointer
454 
455  // next state
456  m_state = 1;
457 
458  // tell caller we don't have a new sample
459  return false;
460 
461  case 1:
462  // insert sample into ring-buffer
463  m_samples[m_ptr][0] = -sample->real();
464  m_samples[m_ptr][1] = -sample->imag();
465 
466  // save result
467  doFIR(sample);
468 
469  // advance write-pointer
471 
472  // next state
473  m_state = 2;
474 
475  // tell caller we have a new sample
476  return true;
477 
478  case 2:
479  // insert sample into ring-buffer
480  m_samples[m_ptr][0] = -sample->imag();
481  m_samples[m_ptr][1] = sample->real();
482 
483  // advance write-pointer
485 
486  // next state
487  m_state = 3;
488 
489  // tell caller we don't have a new sample
490  return false;
491 
492  default:
493  // insert sample into ring-buffer
494  m_samples[m_ptr][0] = sample->real();
495  m_samples[m_ptr][1] = sample->imag();
496 
497  // save result
498  doFIR(sample);
499 
500  // advance write-pointer
502 
503  // next state
504  m_state = 0;
505 
506  // tell caller we have a new sample
507  return true;
508  }
509  }
void doFIR(Sample *sample)
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ workInterpolateCenter()

template<typename AccuType, uint32_t HBFilterOrder>
bool IntHalfbandFilter< AccuType, HBFilterOrder >::workInterpolateCenter ( Sample sampleIn,
Sample SampleOut 
)
inline

Optimized upsampler by 2 not calculating FIR with inserted null samples

Definition at line 117 of file inthalfbandfilter.h.

118  {
119  switch(m_state)
120  {
121  case 0:
122  // return the middle peak
125  m_state = 1; // next state
126  return false; // tell caller we didn't consume the sample
127 
128  default:
129  // calculate with non null samples
130  doInterpolateFIR(SampleOut);
131 
132  // insert sample into ring double buffer
133  m_samples[m_ptr][0] = sampleIn->real();
134  m_samples[m_ptr][1] = sampleIn->imag();
137 
138  // advance pointer
140  m_ptr++;
141  } else {
142  m_ptr = 0;
143  }
144 
145  m_state = 0; // next state
146  return true; // tell caller we consumed the sample
147  }
148  }
void doInterpolateFIR(Sample *sample)
void setImag(FixReal v)
Definition: dsptypes.h:59
void setReal(FixReal v)
Definition: dsptypes.h:58
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ workInterpolateCenterZeroStuffing()

template<typename AccuType, uint32_t HBFilterOrder>
bool IntHalfbandFilter< AccuType, HBFilterOrder >::workInterpolateCenterZeroStuffing ( Sample sampleIn,
Sample SampleOut 
)
inline

Definition at line 76 of file inthalfbandfilter.h.

77  {
78  switch(m_state)
79  {
80  case 0:
81  // insert sample into ring-buffer
82  m_samples[m_ptr][0] = 0;
83  m_samples[m_ptr][1] = 0;
84 
85  // save result
86  doFIR(SampleOut);
87 
88  // advance write-pointer
90 
91  // next state
92  m_state = 1;
93 
94  // tell caller we didn't consume the sample
95  return false;
96 
97  default:
98  // insert sample into ring-buffer
99  m_samples[m_ptr][0] = sampleIn->real();
100  m_samples[m_ptr][1] = sampleIn->imag();
101 
102  // save result
103  doFIR(SampleOut);
104 
105  // advance write-pointer
107 
108  // next state
109  m_state = 0;
110 
111  // tell caller we consumed the sample
112  return true;
113  }
114  }
void doFIR(Sample *sample)
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ workInterpolateLowerHalf()

template<typename AccuType, uint32_t HBFilterOrder>
bool IntHalfbandFilter< AccuType, HBFilterOrder >::workInterpolateLowerHalf ( Sample sampleIn,
Sample sampleOut 
)
inline

Optimized upsampler by 2 not calculating FIR with inserted null samples

Definition at line 376 of file inthalfbandfilter.h.

377  {
378  Sample s;
379 
380  switch(m_state)
381  {
382  case 0:
383  // return the middle peak
384  sampleOut->setReal(m_samples[m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder/4) - 1][1]); // imag
385  sampleOut->setImag(-m_samples[m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder/4) - 1][0]); // - real
386  m_state = 1; // next state
387  return false; // tell caller we didn't consume the sample
388 
389  case 1:
390  // calculate with non null samples
391  doInterpolateFIR(&s);
392  sampleOut->setReal(-s.real());
393  sampleOut->setImag(-s.imag());
394 
395  // insert sample into ring double buffer
396  m_samples[m_ptr][0] = sampleIn->real();
397  m_samples[m_ptr][1] = sampleIn->imag();
400 
401  // advance pointer
403  m_ptr++;
404  } else {
405  m_ptr = 0;
406  }
407 
408  m_state = 2; // next state
409  return true; // tell caller we consumed the sample
410 
411  case 2:
412  // return the middle peak
413  sampleOut->setReal(-m_samples[m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder/4) - 1][1]); // - imag
414  sampleOut->setImag(m_samples[m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder/4) - 1][0]); // real
415  m_state = 3; // next state
416  return false; // tell caller we didn't consume the sample
417 
418  default:
419  // calculate with non null samples
420  doInterpolateFIR(&s);
421  sampleOut->setReal(s.real());
422  sampleOut->setImag(s.imag());
423 
424  // insert sample into ring double buffer
425  m_samples[m_ptr][0] = sampleIn->real();
426  m_samples[m_ptr][1] = sampleIn->imag();
429 
430  // advance pointer
432  m_ptr++;
433  } else {
434  m_ptr = 0;
435  }
436 
437  m_state = 0; // next state
438  return true; // tell caller we consumed the sample
439  }
440  }
void doInterpolateFIR(Sample *sample)
void setImag(FixReal v)
Definition: dsptypes.h:59
void setReal(FixReal v)
Definition: dsptypes.h:58
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ workInterpolateLowerHalfZeroStuffing()

template<typename AccuType, uint32_t HBFilterOrder>
bool IntHalfbandFilter< AccuType, HBFilterOrder >::workInterpolateLowerHalfZeroStuffing ( Sample sampleIn,
Sample sampleOut 
)
inline

Definition at line 291 of file inthalfbandfilter.h.

292  {
293  Sample s;
294 
295  switch(m_state)
296  {
297  case 0:
298  // insert sample into ring-buffer
299  m_samples[m_ptr][0] = 0;
300  m_samples[m_ptr][1] = 0;
301 
302  // save result
303  doFIR(&s);
304  sampleOut->setReal(s.imag());
305  sampleOut->setImag(-s.real());
306 
307  // advance write-pointer
309 
310  // next state
311  m_state = 1;
312 
313  // tell caller we didn't consume the sample
314  return false;
315 
316  case 1:
317  // insert sample into ring-buffer
318  m_samples[m_ptr][0] = sampleIn->real();
319  m_samples[m_ptr][1] = sampleIn->imag();
320 
321  // save result
322  doFIR(&s);
323  sampleOut->setReal(-s.real());
324  sampleOut->setImag(-s.imag());
325 
326  // advance write-pointer
328 
329  // next state
330  m_state = 2;
331 
332  // tell caller we consumed the sample
333  return true;
334 
335  case 2:
336  // insert sample into ring-buffer
337  m_samples[m_ptr][0] = 0;
338  m_samples[m_ptr][1] = 0;
339 
340  // save result
341  doFIR(&s);
342  sampleOut->setReal(-s.imag());
343  sampleOut->setImag(s.real());
344 
345  // advance write-pointer
347 
348  // next state
349  m_state = 3;
350 
351  // tell caller we didn't consume the sample
352  return false;
353 
354  default:
355  // insert sample into ring-buffer
356  m_samples[m_ptr][0] = sampleIn->real();
357  m_samples[m_ptr][1] = sampleIn->imag();
358 
359  // save result
360  doFIR(&s);
361  sampleOut->setReal(s.real());
362  sampleOut->setImag(s.imag());
363 
364  // advance write-pointer
366 
367  // next state
368  m_state = 0;
369 
370  // tell caller we consumed the sample
371  return true;
372  }
373  }
void doFIR(Sample *sample)
void setImag(FixReal v)
Definition: dsptypes.h:59
void setReal(FixReal v)
Definition: dsptypes.h:58
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ workInterpolateUpperHalf()

template<typename AccuType, uint32_t HBFilterOrder>
bool IntHalfbandFilter< AccuType, HBFilterOrder >::workInterpolateUpperHalf ( Sample sampleIn,
Sample sampleOut 
)
inline

Optimized upsampler by 2 not calculating FIR with inserted null samples

Definition at line 597 of file inthalfbandfilter.h.

598  {
599  Sample s;
600 
601  switch(m_state)
602  {
603  case 0:
604  // return the middle peak
605  sampleOut->setReal(-m_samples[m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder/4) - 1][1]); // - imag
606  sampleOut->setImag(m_samples[m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder/4) - 1][0]); // + real
607  m_state = 1; // next state
608  return false; // tell caller we didn't consume the sample
609 
610  case 1:
611  // calculate with non null samples
612  doInterpolateFIR(&s);
613  sampleOut->setReal(-s.real());
614  sampleOut->setImag(-s.imag());
615 
616  // insert sample into ring double buffer
617  m_samples[m_ptr][0] = sampleIn->real();
618  m_samples[m_ptr][1] = sampleIn->imag();
621 
622  // advance pointer
624  m_ptr++;
625  } else {
626  m_ptr = 0;
627  }
628 
629  m_state = 2; // next state
630  return true; // tell caller we consumed the sample
631 
632  case 2:
633  // return the middle peak
634  sampleOut->setReal(m_samples[m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder/4) - 1][1]); // + imag
635  sampleOut->setImag(-m_samples[m_ptr + (HBFIRFilterTraits<HBFilterOrder>::hbOrder/4) - 1][0]); // - real
636  m_state = 3; // next state
637  return false; // tell caller we didn't consume the sample
638 
639  default:
640  // calculate with non null samples
641  doInterpolateFIR(&s);
642  sampleOut->setReal(s.real());
643  sampleOut->setImag(s.imag());
644 
645  // insert sample into ring double buffer
646  m_samples[m_ptr][0] = sampleIn->real();
647  m_samples[m_ptr][1] = sampleIn->imag();
650 
651  // advance pointer
653  m_ptr++;
654  } else {
655  m_ptr = 0;
656  }
657 
658  m_state = 0; // next state
659  return true; // tell caller we consumed the sample
660  }
661  }
void doInterpolateFIR(Sample *sample)
void setImag(FixReal v)
Definition: dsptypes.h:59
void setReal(FixReal v)
Definition: dsptypes.h:58
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

◆ workInterpolateUpperHalfZeroStuffing()

template<typename AccuType, uint32_t HBFilterOrder>
bool IntHalfbandFilter< AccuType, HBFilterOrder >::workInterpolateUpperHalfZeroStuffing ( Sample sampleIn,
Sample sampleOut 
)
inline

Definition at line 512 of file inthalfbandfilter.h.

513  {
514  Sample s;
515 
516  switch(m_state)
517  {
518  case 0:
519  // insert sample into ring-buffer
520  m_samples[m_ptr][0] = 0;
521  m_samples[m_ptr][1] = 0;
522 
523  // save result
524  doFIR(&s);
525  sampleOut->setReal(-s.imag());
526  sampleOut->setImag(s.real());
527 
528  // advance write-pointer
530 
531  // next state
532  m_state = 1;
533 
534  // tell caller we didn't consume the sample
535  return false;
536 
537  case 1:
538  // insert sample into ring-buffer
539  m_samples[m_ptr][0] = sampleIn->real();
540  m_samples[m_ptr][1] = sampleIn->imag();
541 
542  // save result
543  doFIR(&s);
544  sampleOut->setReal(-s.real());
545  sampleOut->setImag(-s.imag());
546 
547  // advance write-pointer
549 
550  // next state
551  m_state = 2;
552 
553  // tell caller we consumed the sample
554  return true;
555 
556  case 2:
557  // insert sample into ring-buffer
558  m_samples[m_ptr][0] = 0;
559  m_samples[m_ptr][1] = 0;
560 
561  // save result
562  doFIR(&s);
563  sampleOut->setReal(s.imag());
564  sampleOut->setImag(-s.real());
565 
566  // advance write-pointer
568 
569  // next state
570  m_state = 3;
571 
572  // tell caller we didn't consume the sample
573  return false;
574 
575  default:
576  // insert sample into ring-buffer
577  m_samples[m_ptr][0] = sampleIn->real();
578  m_samples[m_ptr][1] = sampleIn->imag();
579 
580  // save result
581  doFIR(&s);
582  sampleOut->setReal(s.real());
583  sampleOut->setImag(s.imag());
584 
585  // advance write-pointer
587 
588  // next state
589  m_state = 0;
590 
591  // tell caller we consumed the sample
592  return true;
593  }
594  }
void doFIR(Sample *sample)
void setImag(FixReal v)
Definition: dsptypes.h:59
void setReal(FixReal v)
Definition: dsptypes.h:58
FixReal real() const
Definition: dsptypes.h:61
FixReal imag() const
Definition: dsptypes.h:62
AccuType m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]

Member Data Documentation

◆ m_ptr

template<typename AccuType, uint32_t HBFilterOrder>
qint16 IntHalfbandFilter< AccuType, HBFilterOrder >::m_ptr
protected

Definition at line 785 of file inthalfbandfilter.h.

◆ m_samples

template<typename AccuType, uint32_t HBFilterOrder>
AccuType IntHalfbandFilter< AccuType, HBFilterOrder >::m_samples[HBFIRFilterTraits< HBFilterOrder >::hbOrder+1][2]
protected

Definition at line 784 of file inthalfbandfilter.h.

◆ m_state

template<typename AccuType, uint32_t HBFilterOrder>
int IntHalfbandFilter< AccuType, HBFilterOrder >::m_state
protected

Definition at line 786 of file inthalfbandfilter.h.


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