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 Member Functions | Private Attributes | List of all members
leansdr::fir_sampler< T, Tc > Struct Template Reference

#include <sdr.h>

+ Inheritance diagram for leansdr::fir_sampler< T, Tc >:
+ Collaboration diagram for leansdr::fir_sampler< T, Tc >:

Public Member Functions

 fir_sampler (int _ncoeffs, Tc *_coeffs, int _subsampling=1)
 
int readahead ()
 
complex< T > interp (const complex< T > *pin, float mu, float phase)
 
void update_freq (float freqw, int period)
 
- Public Member Functions inherited from leansdr::sampler_interface< T >
virtual ~sampler_interface ()
 

Private Member Functions

void do_update_freq (float freqw)
 

Private Attributes

trig16 trig
 
int ncoeffs
 
Tc * coeffs
 
int subsampling
 
cf32shifted_coeffs
 
int update_freq_phase
 

Detailed Description

template<typename T, typename Tc>
struct leansdr::fir_sampler< T, Tc >

Definition at line 958 of file sdr.h.

Constructor & Destructor Documentation

◆ fir_sampler()

template<typename T, typename Tc>
leansdr::fir_sampler< T, Tc >::fir_sampler ( int  _ncoeffs,
Tc *  _coeffs,
int  _subsampling = 1 
)
inline

Definition at line 960 of file sdr.h.

960  : ncoeffs(_ncoeffs),
961  coeffs(_coeffs),
962  subsampling(_subsampling),
963  shifted_coeffs(new complex<T>[ncoeffs]),
965  {
966  do_update_freq(0); // In case application never calls update_freq()
967  }
int update_freq_phase
Definition: sdr.h:1027
cf32 * shifted_coeffs
Definition: sdr.h:1026
void do_update_freq(float freqw)
Definition: sdr.h:1015

Member Function Documentation

◆ do_update_freq()

template<typename T, typename Tc>
void leansdr::fir_sampler< T, Tc >::do_update_freq ( float  freqw)
inlineprivate

Definition at line 1015 of file sdr.h.

References leansdr::auto_notch< T >::slot::i.

1016  {
1017  float f = freqw / subsampling;
1018  for (int i = 0; i < ncoeffs; ++i)
1019  shifted_coeffs[i] = trig.expi(-f * (i - ncoeffs / 2)) * coeffs[i];
1020  }
cf32 * shifted_coeffs
Definition: sdr.h:1026
int32_t i
Definition: decimators.h:244
const complex< float > & expi(uint16_t a) const
Definition: math.h:146

◆ interp()

template<typename T, typename Tc>
complex<T> leansdr::fir_sampler< T, Tc >::interp ( const complex< T > *  pin,
float  mu,
float  phase 
)
inlinevirtual

Implements leansdr::sampler_interface< T >.

Definition at line 974 of file sdr.h.

975  {
976  // Apply FIR filter with subsampling
977  complex<T> acc(0, 0);
978  complex<T> *pc = shifted_coeffs + (int)((1 - mu) * subsampling);
979  complex<T> *pcend = shifted_coeffs + ncoeffs;
980 
981  if (subsampling == 1)
982  {
983  // Special case for heavily oversampled signals,
984  // where filtering is expensive.
985  // gcc-4.9.2 can vectorize this form with NEON on ARM.
986  while (pc < pcend)
987  acc += (*pc++) * (*pin++);
988  }
989  else
990  {
991  // Not vectorized because the coefficients are not
992  // guaranteed to be contiguous in memory.
993  for (; pc < pcend; pc += subsampling, ++pin)
994  acc += (*pc) * (*pin);
995  }
996 
997  // Derotate
998  return trig.expi(-phase) * acc;
999  }
cf32 * shifted_coeffs
Definition: sdr.h:1026
const complex< float > & expi(uint16_t a) const
Definition: math.h:146

◆ readahead()

template<typename T, typename Tc>
int leansdr::fir_sampler< T, Tc >::readahead ( )
inlinevirtual

Implements leansdr::sampler_interface< T >.

Definition at line 969 of file sdr.h.

970  {
971  return ncoeffs - 1;
972  }

◆ update_freq()

template<typename T, typename Tc>
void leansdr::fir_sampler< T, Tc >::update_freq ( float  freqw,
int  period 
)
inlinevirtual

Reimplemented from leansdr::sampler_interface< T >.

Definition at line 1001 of file sdr.h.

1002  {
1003  // Throttling: Update one coeff per 16 processed samples,
1004  // to keep the overhead of freq tracking below about 10%.
1005  update_freq_phase -= period;
1006 
1007  if (update_freq_phase <= 0)
1008  {
1009  update_freq_phase = ncoeffs * 16;
1010  do_update_freq(freqw);
1011  }
1012  }
int update_freq_phase
Definition: sdr.h:1027
void do_update_freq(float freqw)
Definition: sdr.h:1015

Member Data Documentation

◆ coeffs

template<typename T, typename Tc>
Tc* leansdr::fir_sampler< T, Tc >::coeffs
private

Definition at line 1024 of file sdr.h.

◆ ncoeffs

template<typename T, typename Tc>
int leansdr::fir_sampler< T, Tc >::ncoeffs
private

Definition at line 1023 of file sdr.h.

◆ shifted_coeffs

template<typename T, typename Tc>
cf32* leansdr::fir_sampler< T, Tc >::shifted_coeffs
private

Definition at line 1026 of file sdr.h.

◆ subsampling

template<typename T, typename Tc>
int leansdr::fir_sampler< T, Tc >::subsampling
private

Definition at line 1025 of file sdr.h.

◆ trig

template<typename T, typename Tc>
trig16 leansdr::fir_sampler< T, Tc >::trig
private

Definition at line 1022 of file sdr.h.

◆ update_freq_phase

template<typename T, typename Tc>
int leansdr::fir_sampler< T, Tc >::update_freq_phase
private

Definition at line 1027 of file sdr.h.


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