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 Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
fftfilt Class Reference

#include <fftfilt.h>

+ Collaboration diagram for fftfilt:

Public Types

typedef std::complex< float > cmplx
 

Public Member Functions

 fftfilt (float f1, float f2, int len)
 
 fftfilt (float f2, int len)
 
 ~fftfilt ()
 
void create_filter (float f1, float f2)
 
void create_dsb_filter (float f2)
 
void create_asym_filter (float fopp, float fin)
 two different filters for in band and opposite band More...
 
void create_rrc_filter (float fb, float a)
 root raised cosine. fb is half the band pass More...
 
int noFilt (const cmplx &in, cmplx **out)
 
int runFilt (const cmplx &in, cmplx **out)
 
int runSSB (const cmplx &in, cmplx **out, bool usb, bool getDC=true)
 
int runDSB (const cmplx &in, cmplx **out, bool getDC=true)
 
int runAsym (const cmplx &in, cmplx **out, bool usb)
 Asymmetrical fitering can be used for vestigial sideband. More...
 

Protected Member Functions

float fsinc (float fc, int i, int len)
 
float _blackman (int i, int len)
 
cmplx frrc (float fb, float a, int i, int len)
 
void init_filter ()
 
void init_dsb_filter ()
 

Protected Attributes

int flen
 
int flen2
 
g_fft< float > * fft
 
cmplxfilter
 
cmplxfilterOpp
 
cmplxdata
 
cmplxovlbuf
 
cmplxoutput
 
int inptr
 
int pass
 
int window
 

Private Types

enum  { NONE, BLACKMAN, HAMMING, HANNING }
 

Detailed Description

Definition at line 17 of file fftfilt.h.

Member Typedef Documentation

◆ cmplx

typedef std::complex<float> fftfilt::cmplx

Definition at line 21 of file fftfilt.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
NONE 
BLACKMAN 
HAMMING 
HANNING 

Definition at line 18 of file fftfilt.h.

Constructor & Destructor Documentation

◆ fftfilt() [1/2]

fftfilt::fftfilt ( float  f1,
float  f2,
int  len 
)

Definition at line 78 of file fftfilt.cpp.

References create_filter(), flen, init_filter(), pass, and window.

79 {
80  flen = len;
81  pass = 0;
82  window = 0;
83  init_filter();
84  create_filter(f1, f2);
85 }
int pass
Definition: fftfilt.h:49
int flen
Definition: fftfilt.h:40
void create_filter(float f1, float f2)
Definition: fftfilt.cpp:107
void init_filter()
Definition: fftfilt.cpp:51
int window
Definition: fftfilt.h:50
+ Here is the call graph for this function:

◆ fftfilt() [2/2]

fftfilt::fftfilt ( float  f2,
int  len 
)

Definition at line 87 of file fftfilt.cpp.

References create_dsb_filter(), flen, init_filter(), pass, and window.

88 {
89  flen = len;
90  pass = 0;
91  window = 0;
92  init_filter();
94 }
int pass
Definition: fftfilt.h:49
int flen
Definition: fftfilt.h:40
void init_filter()
Definition: fftfilt.cpp:51
void create_dsb_filter(float f2)
Definition: fftfilt.cpp:148
int window
Definition: fftfilt.h:50
+ Here is the call graph for this function:

◆ ~fftfilt()

fftfilt::~fftfilt ( )

Definition at line 96 of file fftfilt.cpp.

References data, fft, filter, filterOpp, output, and ovlbuf.

97 {
98  if (fft) delete fft;
99 
100  if (filter) delete [] filter;
101  if (filterOpp) delete [] filterOpp;
102  if (data) delete [] data;
103  if (output) delete [] output;
104  if (ovlbuf) delete [] ovlbuf;
105 }
cmplx * ovlbuf
Definition: fftfilt.h:46
cmplx * filterOpp
Definition: fftfilt.h:44
cmplx * filter
Definition: fftfilt.h:43
g_fft< float > * fft
Definition: fftfilt.h:42
cmplx * output
Definition: fftfilt.h:47
cmplx * data
Definition: fftfilt.h:45

Member Function Documentation

◆ _blackman()

float fftfilt::_blackman ( int  i,
int  len 
)
inlineprotected

Definition at line 59 of file fftfilt.h.

References cos(), and M_PI.

Referenced by create_asym_filter(), create_dsb_filter(), and create_filter().

60  {
61  return (0.42 -
62  0.50 * cos(2.0 * M_PI * i / len) +
63  0.08 * cos(4.0 * M_PI * i / len));
64  }
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
#define M_PI
Definition: fftfilt.h:13
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_asym_filter()

void fftfilt::create_asym_filter ( float  fopp,
float  fin 
)

two different filters for in band and opposite band

Definition at line 174 of file fftfilt.cpp.

References _blackman(), abs(), g_fft< FFT_TYPE >::ComplexFFT(), fft, filter, filterOpp, flen, flen2, fsinc(), and i.

Referenced by ATVDemod::applySettings(), and ATVMod::applySettings().

175 {
176  // in band
177  // initialize the filter to zero
178  memset(filter, 0, flen * sizeof(cmplx));
179 
180  for (int i = 0; i < flen2; i++) {
181  filter[i] = fsinc(fin, i, flen2);
182  filter[i] *= _blackman(i, flen2);
183  }
184 
185  fft->ComplexFFT(filter); // filter was expressed in the time domain (impulse response)
186 
187  // normalize the output filter for unity gain
188  float scale = 0, mag;
189  for (int i = 0; i < flen2; i++) {
190  mag = abs(filter[i]);
191  if (mag > scale) scale = mag;
192  }
193  if (scale != 0) {
194  for (int i = 0; i < flen; i++)
195  filter[i] /= scale;
196  }
197 
198  // opposite band
199  // initialize the filter to zero
200  memset(filterOpp, 0, flen * sizeof(cmplx));
201 
202  for (int i = 0; i < flen2; i++) {
203  filterOpp[i] = fsinc(fopp, i, flen2);
204  filterOpp[i] *= _blackman(i, flen2);
205  }
206 
207  fft->ComplexFFT(filterOpp); // filter was expressed in the time domain (impulse response)
208 
209  // normalize the output filter for unity gain
210  scale = 0;
211  for (int i = 0; i < flen2; i++) {
212  mag = abs(filterOpp[i]);
213  if (mag > scale) scale = mag;
214  }
215  if (scale != 0) {
216  for (int i = 0; i < flen; i++)
217  filterOpp[i] /= scale;
218  }
219 }
int flen
Definition: fftfilt.h:40
std::complex< float > cmplx
Definition: complex.h:31
Fixed< IntType, IntBits > abs(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2313
float _blackman(int i, int len)
Definition: fftfilt.h:59
float fsinc(float fc, int i, int len)
Definition: fftfilt.h:52
void ComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3309
cmplx * filterOpp
Definition: fftfilt.h:44
int32_t i
Definition: decimators.h:244
cmplx * filter
Definition: fftfilt.h:43
int flen2
Definition: fftfilt.h:41
g_fft< float > * fft
Definition: fftfilt.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_dsb_filter()

void fftfilt::create_dsb_filter ( float  f2)

Definition at line 148 of file fftfilt.cpp.

References _blackman(), abs(), g_fft< FFT_TYPE >::ComplexFFT(), fft, filter, flen, flen2, fsinc(), and i.

Referenced by AMDemod::applyAudioSampleRate(), SSBDemod::applyAudioSampleRate(), SSBMod::applyAudioSampleRate(), AMDemod::applySettings(), SSBDemod::applySettings(), SSBMod::applySettings(), fftfilt(), and ChannelAnalyzer::setFilters().

149 {
150  // initialize the filter to zero
151  memset(filter, 0, flen * sizeof(cmplx));
152 
153  for (int i = 0; i < flen2; i++) {
154  filter[i] = fsinc(f2, i, flen2);
155  filter[i] *= _blackman(i, flen2);
156  }
157 
158  fft->ComplexFFT(filter); // filter was expressed in the time domain (impulse response)
159 
160  // normalize the output filter for unity gain
161  float scale = 0, mag;
162  for (int i = 0; i < flen2; i++) {
163  mag = abs(filter[i]);
164  if (mag > scale) scale = mag;
165  }
166  if (scale != 0) {
167  for (int i = 0; i < flen; i++)
168  filter[i] /= scale;
169  }
170 }
int flen
Definition: fftfilt.h:40
std::complex< float > cmplx
Definition: complex.h:31
Fixed< IntType, IntBits > abs(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2313
float _blackman(int i, int len)
Definition: fftfilt.h:59
float fsinc(float fc, int i, int len)
Definition: fftfilt.h:52
void ComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3309
int32_t i
Definition: decimators.h:244
cmplx * filter
Definition: fftfilt.h:43
int flen2
Definition: fftfilt.h:41
g_fft< float > * fft
Definition: fftfilt.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_filter()

void fftfilt::create_filter ( float  f1,
float  f2 
)

Definition at line 107 of file fftfilt.cpp.

References _blackman(), abs(), g_fft< FFT_TYPE >::ComplexFFT(), fft, filter, flen, flen2, fsinc(), and i.

Referenced by SSBDemod::applyAudioSampleRate(), SSBMod::applyAudioSampleRate(), WFMDemod::applyChannelSettings(), BFMDemod::applyChannelSettings(), WFMMod::applyChannelSettings(), DATVDemod::applyChannelSettings(), ATVMod::applyChannelSettings(), FreeDVMod::applyFreeDVMode(), FreeDVDemod::applyFreeDVMode(), WFMDemod::applySettings(), UDPSource::applySettings(), BFMDemod::applySettings(), WFMMod::applySettings(), SSBDemod::applySettings(), SSBMod::applySettings(), DATVDemod::applySettings(), ATVMod::applySettings(), fftfilt(), and ChannelAnalyzer::setFilters().

108 {
109  // initialize the filter to zero
110  memset(filter, 0, flen * sizeof(cmplx));
111 
112  // create the filter shape coefficients by fft
113  bool b_lowpass, b_highpass;
114  b_lowpass = (f2 != 0);
115  b_highpass = (f1 != 0);
116 
117  for (int i = 0; i < flen2; i++) {
118  filter[i] = 0;
119  // lowpass @ f2
120  if (b_lowpass)
121  filter[i] += fsinc(f2, i, flen2);
122  // highighpass @ f1
123  if (b_highpass)
124  filter[i] -= fsinc(f1, i, flen2);
125  }
126  // highpass is delta[flen2/2] - h(t)
127  if (b_highpass && f2 < f1)
128  filter[flen2 / 2] += 1;
129 
130  for (int i = 0; i < flen2; i++)
131  filter[i] *= _blackman(i, flen2);
132 
133  fft->ComplexFFT(filter); // filter was expressed in the time domain (impulse response)
134 
135  // normalize the output filter for unity gain
136  float scale = 0, mag;
137  for (int i = 0; i < flen2; i++) {
138  mag = abs(filter[i]);
139  if (mag > scale) scale = mag;
140  }
141  if (scale != 0) {
142  for (int i = 0; i < flen; i++)
143  filter[i] /= scale;
144  }
145 }
int flen
Definition: fftfilt.h:40
std::complex< float > cmplx
Definition: complex.h:31
Fixed< IntType, IntBits > abs(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2313
float _blackman(int i, int len)
Definition: fftfilt.h:59
float fsinc(float fc, int i, int len)
Definition: fftfilt.h:52
void ComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3309
int32_t i
Definition: decimators.h:244
cmplx * filter
Definition: fftfilt.h:43
int flen2
Definition: fftfilt.h:41
g_fft< float > * fft
Definition: fftfilt.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_rrc_filter()

void fftfilt::create_rrc_filter ( float  fb,
float  a 
)

root raised cosine. fb is half the band pass

Definition at line 222 of file fftfilt.cpp.

References abs(), filter, flen, frrc(), and i.

Referenced by ChannelAnalyzer::applySettings(), ChannelAnalyzer::setFilters(), and FreqTracker::setInterpolator().

223 {
224  std::fill(filter, filter+flen, 0);
225 
226  for (int i = 0; i < flen; i++) {
227  filter[i] = frrc(fb, a, i, flen);
228  }
229 
230  // normalize the output filter for unity gain
231  float scale = 0, mag;
232  for (int i = 0; i < flen; i++)
233  {
234  mag = abs(filter[i]);
235  if (mag > scale) {
236  scale = mag;
237  }
238  }
239  if (scale != 0)
240  {
241  for (int i = 0; i < flen; i++) {
242  filter[i] /= scale;
243  }
244  }
245 }
int flen
Definition: fftfilt.h:40
cmplx frrc(float fb, float a, int i, int len)
Definition: fftfilt.h:68
Fixed< IntType, IntBits > abs(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2313
int32_t i
Definition: decimators.h:244
cmplx * filter
Definition: fftfilt.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ frrc()

cmplx fftfilt::frrc ( float  fb,
float  a,
int  i,
int  len 
)
inlineprotected

RRC function in the frequency domain. Zero frequency is on the sides with first half in positive frequencies and second half in negative frequencies

Definition at line 68 of file fftfilt.h.

References cos(), and M_PI.

Referenced by create_rrc_filter().

69  {
70  float x = i/(float)len; // normalize to [0..1]
71  x = 0.5-fabs(x-0.5); // apply symmetry: now both halves overlap near 0
72  float tr = fb*a; // half the transition zone
73 
74  if (x < fb-tr)
75  {
76  return 1.0; // in band
77  }
78  else if (x < fb+tr) // transition
79  {
80  float y = ((x-(fb-tr)) / (2.0*tr))*M_PI;
81  return (cos(y) + 1.0f)/2.0f;
82  }
83  else
84  {
85  return 0.0; // out of band
86  }
87  }
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
#define M_PI
Definition: fftfilt.h:13
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fsinc()

float fftfilt::fsinc ( float  fc,
int  i,
int  len 
)
inlineprotected

Definition at line 52 of file fftfilt.h.

References M_PI, and sin().

Referenced by create_asym_filter(), create_dsb_filter(), and create_filter().

53  {
54  int len2 = len/2;
55  return (i == len2) ? 2.0 * fc:
56  sin(2 * M_PI * fc * (i - len2)) / (M_PI * (i - len2));
57  }
#define M_PI
Definition: fftfilt.h:13
Fixed< IntType, IntBits > sin(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2265
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_dsb_filter()

void fftfilt::init_dsb_filter ( )
protected

◆ init_filter()

void fftfilt::init_filter ( )
protected

Definition at line 51 of file fftfilt.cpp.

References data, fft, filter, filterOpp, flen, flen2, inptr, output, and ovlbuf.

Referenced by fftfilt().

52 {
53  flen2 = flen >> 1;
54  fft = new g_fft<float>(flen);
55 
56  filter = new cmplx[flen];
57  filterOpp = new cmplx[flen];
58  data = new cmplx[flen];
59  output = new cmplx[flen2];
60  ovlbuf = new cmplx[flen2];
61 
62  memset(filter, 0, flen * sizeof(cmplx));
63  memset(filterOpp, 0, flen * sizeof(cmplx));
64  memset(data, 0, flen * sizeof(cmplx));
65  memset(output, 0, flen2 * sizeof(cmplx));
66  memset(ovlbuf, 0, flen2 * sizeof(cmplx));
67 
68  inptr = 0;
69 }
int flen
Definition: fftfilt.h:40
cmplx * ovlbuf
Definition: fftfilt.h:46
std::complex< float > cmplx
Definition: complex.h:31
cmplx * filterOpp
Definition: fftfilt.h:44
cmplx * filter
Definition: fftfilt.h:43
int flen2
Definition: fftfilt.h:41
g_fft< float > * fft
Definition: fftfilt.h:42
cmplx * output
Definition: fftfilt.h:47
cmplx * data
Definition: fftfilt.h:45
int inptr
Definition: fftfilt.h:48
+ Here is the caller graph for this function:

◆ noFilt()

int fftfilt::noFilt ( const cmplx in,
cmplx **  out 
)

Definition at line 248 of file fftfilt.cpp.

References data, flen2, and inptr.

249 {
250  data[inptr++] = in;
251  if (inptr < flen2)
252  return 0;
253  inptr = 0;
254 
255  *out = data;
256  return flen2;
257 }
int flen2
Definition: fftfilt.h:41
cmplx * data
Definition: fftfilt.h:45
int inptr
Definition: fftfilt.h:48

◆ runAsym()

int fftfilt::runAsym ( const cmplx in,
cmplx **  out,
bool  usb 
)

Asymmetrical fitering can be used for vestigial sideband.

Definition at line 360 of file fftfilt.cpp.

References g_fft< FFT_TYPE >::ComplexFFT(), data, fft, filter, filterOpp, flen, flen2, i, inptr, g_fft< FFT_TYPE >::InverseComplexFFT(), output, and ovlbuf.

Referenced by ATVDemod::demod(), and ATVMod::modulateVestigialSSB().

361 {
362  data[inptr++] = in;
363  if (inptr < flen2)
364  return 0;
365  inptr = 0;
366 
367  fft->ComplexFFT(data);
368 
369  data[0] *= filter[0]; // always keep DC
370 
371  if (usb)
372  {
373  for (int i = 1; i < flen2; i++)
374  {
375  data[i] *= filter[i]; // usb
376  data[flen2 + i] *= filterOpp[flen2 + i]; // lsb is the opposite
377  }
378  }
379  else
380  {
381  for (int i = 1; i < flen2; i++)
382  {
383  data[i] *= filterOpp[i]; // usb is the opposite
384  data[flen2 + i] *= filter[flen2 + i]; // lsb
385  }
386  }
387 
388  // in-place FFT: freqdata overwritten with filtered timedata
390 
391  // overlap and add
392  for (int i = 0; i < flen2; i++) {
393  output[i] = ovlbuf[i] + data[i];
394  ovlbuf[i] = data[i+flen2];
395  }
396 
397  memset (data, 0, flen * sizeof(cmplx));
398 
399  *out = output;
400  return flen2;
401 }
int flen
Definition: fftfilt.h:40
cmplx * ovlbuf
Definition: fftfilt.h:46
void InverseComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3325
std::complex< float > cmplx
Definition: complex.h:31
void ComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3309
cmplx * filterOpp
Definition: fftfilt.h:44
int32_t i
Definition: decimators.h:244
cmplx * filter
Definition: fftfilt.h:43
int flen2
Definition: fftfilt.h:41
g_fft< float > * fft
Definition: fftfilt.h:42
cmplx * output
Definition: fftfilt.h:47
cmplx * data
Definition: fftfilt.h:45
int inptr
Definition: fftfilt.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ runDSB()

int fftfilt::runDSB ( const cmplx in,
cmplx **  out,
bool  getDC = true 
)

Definition at line 327 of file fftfilt.cpp.

References g_fft< FFT_TYPE >::ComplexFFT(), data, fft, filter, flen, flen2, i, inptr, g_fft< FFT_TYPE >::InverseComplexFFT(), output, and ovlbuf.

Referenced by ChannelAnalyzer::processOneSample(), AMDemod::processOneSample(), SSBDemod::processOneSample(), and SSBMod::pullAF().

328 {
329  data[inptr++] = in;
330  if (inptr < flen2)
331  return 0;
332  inptr = 0;
333 
334  fft->ComplexFFT(data);
335 
336  for (int i = 0; i < flen2; i++) {
337  data[i] *= filter[i];
338  data[flen2 + i] *= filter[flen2 + i];
339  }
340 
341  // get or reject DC component
342  data[0] = getDC ? data[0] : 0;
343 
344  // in-place FFT: freqdata overwritten with filtered timedata
346 
347  // overlap and add
348  for (int i = 0; i < flen2; i++) {
349  output[i] = ovlbuf[i] + data[i];
350  ovlbuf[i] = data[i+flen2];
351  }
352 
353  memset (data, 0, flen * sizeof(cmplx));
354 
355  *out = output;
356  return flen2;
357 }
int flen
Definition: fftfilt.h:40
cmplx * ovlbuf
Definition: fftfilt.h:46
void InverseComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3325
std::complex< float > cmplx
Definition: complex.h:31
void ComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3309
int32_t i
Definition: decimators.h:244
cmplx * filter
Definition: fftfilt.h:43
int flen2
Definition: fftfilt.h:41
g_fft< float > * fft
Definition: fftfilt.h:42
cmplx * output
Definition: fftfilt.h:47
cmplx * data
Definition: fftfilt.h:45
int inptr
Definition: fftfilt.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ runFilt()

int fftfilt::runFilt ( const cmplx in,
cmplx **  out 
)

Definition at line 260 of file fftfilt.cpp.

References g_fft< FFT_TYPE >::ComplexFFT(), data, fft, filter, flen, flen2, i, inptr, g_fft< FFT_TYPE >::InverseComplexFFT(), output, and ovlbuf.

Referenced by WFMDemod::feed(), BFMDemod::feed(), DATVDemod::feed(), ChannelAnalyzer::processOneSample(), FreqTracker::processOneSample(), and WFMMod::pull().

261 {
262  data[inptr++] = in;
263  if (inptr < flen2)
264  return 0;
265  inptr = 0;
266 
267  fft->ComplexFFT(data);
268  for (int i = 0; i < flen; i++)
269  data[i] *= filter[i];
270 
272 
273  for (int i = 0; i < flen2; i++) {
274  output[i] = ovlbuf[i] + data[i];
275  ovlbuf[i] = data[flen2 + i];
276  }
277  memset (data, 0, flen * sizeof(cmplx));
278 
279  *out = output;
280  return flen2;
281 }
int flen
Definition: fftfilt.h:40
cmplx * ovlbuf
Definition: fftfilt.h:46
void InverseComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3325
std::complex< float > cmplx
Definition: complex.h:31
void ComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3309
int32_t i
Definition: decimators.h:244
cmplx * filter
Definition: fftfilt.h:43
int flen2
Definition: fftfilt.h:41
g_fft< float > * fft
Definition: fftfilt.h:42
cmplx * output
Definition: fftfilt.h:47
cmplx * data
Definition: fftfilt.h:45
int inptr
Definition: fftfilt.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ runSSB()

int fftfilt::runSSB ( const cmplx in,
cmplx **  out,
bool  usb,
bool  getDC = true 
)

Definition at line 284 of file fftfilt.cpp.

References g_fft< FFT_TYPE >::ComplexFFT(), data, fft, filter, flen, flen2, i, inptr, g_fft< FFT_TYPE >::InverseComplexFFT(), output, and ovlbuf.

Referenced by UDPSink::feed(), UDPSource::modulateSample(), ATVMod::modulateSSB(), ChannelAnalyzer::processOneSample(), AMDemod::processOneSample(), SSBDemod::processOneSample(), FreeDVDemod::processOneSample(), FreeDVMod::pullAF(), and SSBMod::pullAF().

285 {
286  data[inptr++] = in;
287  if (inptr < flen2)
288  return 0;
289  inptr = 0;
290 
291  fft->ComplexFFT(data);
292 
293  // get or reject DC component
294  data[0] = getDC ? data[0]*filter[0] : 0;
295 
296  // Discard frequencies for ssb
297  if (usb)
298  {
299  for (int i = 1; i < flen2; i++) {
300  data[i] *= filter[i];
301  data[flen2 + i] = 0;
302  }
303  }
304  else
305  {
306  for (int i = 1; i < flen2; i++) {
307  data[i] = 0;
308  data[flen2 + i] *= filter[flen2 + i];
309  }
310  }
311 
312  // in-place FFT: freqdata overwritten with filtered timedata
314 
315  // overlap and add
316  for (int i = 0; i < flen2; i++) {
317  output[i] = ovlbuf[i] + data[i];
318  ovlbuf[i] = data[i+flen2];
319  }
320  memset (data, 0, flen * sizeof(cmplx));
321 
322  *out = output;
323  return flen2;
324 }
int flen
Definition: fftfilt.h:40
cmplx * ovlbuf
Definition: fftfilt.h:46
void InverseComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3325
std::complex< float > cmplx
Definition: complex.h:31
void ComplexFFT(std::complex< FFT_TYPE > *buf)
Definition: gfft.h:3309
int32_t i
Definition: decimators.h:244
cmplx * filter
Definition: fftfilt.h:43
int flen2
Definition: fftfilt.h:41
g_fft< float > * fft
Definition: fftfilt.h:42
cmplx * output
Definition: fftfilt.h:47
cmplx * data
Definition: fftfilt.h:45
int inptr
Definition: fftfilt.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ data

cmplx* fftfilt::data
protected

Definition at line 45 of file fftfilt.h.

Referenced by init_filter(), noFilt(), runAsym(), runDSB(), runFilt(), runSSB(), and ~fftfilt().

◆ fft

g_fft<float>* fftfilt::fft
protected

◆ filter

cmplx* fftfilt::filter
protected

◆ filterOpp

cmplx* fftfilt::filterOpp
protected

Definition at line 44 of file fftfilt.h.

Referenced by create_asym_filter(), init_filter(), runAsym(), and ~fftfilt().

◆ flen

int fftfilt::flen
protected

◆ flen2

int fftfilt::flen2
protected

◆ inptr

int fftfilt::inptr
protected

Definition at line 48 of file fftfilt.h.

Referenced by init_filter(), noFilt(), runAsym(), runDSB(), runFilt(), and runSSB().

◆ output

cmplx* fftfilt::output
protected

Definition at line 47 of file fftfilt.h.

Referenced by init_filter(), runAsym(), runDSB(), runFilt(), runSSB(), and ~fftfilt().

◆ ovlbuf

cmplx* fftfilt::ovlbuf
protected

Definition at line 46 of file fftfilt.h.

Referenced by init_filter(), runAsym(), runDSB(), runFilt(), runSSB(), and ~fftfilt().

◆ pass

int fftfilt::pass
protected

Definition at line 49 of file fftfilt.h.

Referenced by fftfilt().

◆ window

int fftfilt::window
protected

Definition at line 50 of file fftfilt.h.

Referenced by fftfilt().


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