SoDaRadio-5.0.3-master:8901fb5
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SoDa::OSFilter Class Reference

Overlap-and-save filter class. More...

#include <OSFilter.hxx>

Public Member Functions

 OSFilter (float low_cutoff, float low_pass_edge, float high_pass_edge, float high_cutoff, unsigned int filter_length, float filter_gain, float sample_rate, unsigned int inout_buffer_length, unsigned int suggested_transform_length=0)
 constructor More...
 
unsigned int apply (std::complex< float > *inbuf, std::complex< float > *outbuf, float outgain=1.0)
 run the filter on a complex input stream More...
 
unsigned int apply (float *inbuf, float *outbuf, float outgain=1.0, int instride=1, int outstride=1)
 run the filter on a real input stream More...
 
void dump (std::ostream &os)
 dump the filter FFT to the output stream More...
 
std::pair< double, double > getFilterEdges ()
 

Protected Member Functions

int guessN ()
 pick a likely N - FFT length. More...
 
void setupFFT ()
 

Protected Attributes

double low_edge
 parameters that we keep to support display masks on the spectrogram More...
 
double high_edge
 
unsigned int M
 the input buffer length; More...
 
unsigned int Q
 the filter length More...
 
unsigned int N
 the total length of the transform N > (M + Q-1) More...
 
unsigned int tail_index
 the beginning of the end. More...
 
std::complex< float > * fft_input
 a copy of the input stream. More...
 
std::complex< float > * fft_output
 the transformed input stream + overlap More...
 
std::complex< float > * ifft_output
 the output stream + overlap discard More...
 
std::complex< float > * filter_fft
 FFT image of the input filter. More...
 
fftwf_plan forward_plan
 
fftwf_plan backward_plan
 plans for fftw transform ops More...
 

Detailed Description

Overlap-and-save filter class.

Definition at line 50 of file OSFilter.hxx.

Constructor & Destructor Documentation

◆ OSFilter()

SoDa::OSFilter::OSFilter ( float  low_cutoff,
float  low_pass_edge,
float  high_pass_edge,
float  high_cutoff,
unsigned int  filter_length,
float  filter_gain,
float  sample_rate,
unsigned int  inout_buffer_length,
unsigned int  suggested_transform_length = 0 
)

constructor

constructor Build the filter from a filter spec for a bandpass filter

Parameters
low_cutofffrequency below which the response is (ideally) zero
low_pass_edgelow end of the bandpass range
high_pass_edgehigh end of the bandpass range
high_cutofffrequency above which the response is (ideally) zero
filter_lengthminimum number of effective filter taps
filter_gaindesired gain in passband
sample_ratein samples/sec to allow normalization of the frequency specs
inout_buffer_lengthused to set aside storage for overlap and save buffer
suggested_transform_lengtha hint for optimizing FFT operations

Definition at line 123 of file OSFilter.cxx.

References filter_fft, guessN(), high_edge, low_edge, M, N, Q, setupFFT(), and tail_index.

Referenced by ipow().

Member Function Documentation

◆ apply() [1/2]

unsigned int SoDa::OSFilter::apply ( std::complex< float > *  inbuf,
std::complex< float > *  outbuf,
float  outgain = 1.0 
)

run the filter on a complex input stream

Parameters
inbufthe input buffer I/Q samples (complex)
outbufthe output buffer I/Q samples (complex)
outgainnormalized output gain
Returns
the length of the input buffer

Definition at line 334 of file OSFilter.cxx.

References backward_plan, fft_input, fft_output, filter_fft, forward_plan, ifft_output, M, N, Q, and tail_index.

Referenced by SoDa::BaseBandRX::demodulate(), SoDa::BaseBandRX::demodulateAM(), SoDa::BaseBandRX::demodulateNBFM(), SoDa::BaseBandRX::demodulateWBFM(), main(), and SoDa::BaseBandTX::run().

◆ apply() [2/2]

unsigned int SoDa::OSFilter::apply ( float *  inbuf,
float *  outbuf,
float  outgain = 1.0,
int  instride = 1,
int  outstride = 1 
)

run the filter on a real input stream

Parameters
inbufthe input buffer samples
outbufthe output buffer samples (this can overlap the inbuf vector)
outgainnormalized output gain
instrideindex increment for the input buffer
outstrideindex increment for the output buffer
Returns
the length of the input buffer

Definition at line 298 of file OSFilter.cxx.

References backward_plan, fft_input, fft_output, filter_fft, forward_plan, ifft_output, M, N, Q, and tail_index.

◆ dump()

void SoDa::OSFilter::dump ( std::ostream &  os)

dump the filter FFT to the output stream

Parameters
osan output stream.

Definition at line 364 of file OSFilter.cxx.

References filter_fft, and N.

Referenced by buildFilterMap().

◆ getFilterEdges()

std::pair<double, double> SoDa::OSFilter::getFilterEdges ( )
inline

Definition at line 117 of file OSFilter.hxx.

References high_edge, and low_edge.

Referenced by SoDa::BaseBandRX::repAFFilterShape().

◆ guessN()

int SoDa::OSFilter::guessN ( )
protected

pick a likely N - FFT length.

Definition at line 248 of file OSFilter.cxx.

References ipow(), M, and Q.

Referenced by ipow(), and OSFilter().

◆ setupFFT()

void SoDa::OSFilter::setupFFT ( )
protected

Definition at line 275 of file OSFilter.cxx.

References backward_plan, fft_input, fft_output, forward_plan, ifft_output, N, and Q.

Referenced by ipow(), and OSFilter().

Member Data Documentation

◆ backward_plan

fftwf_plan SoDa::OSFilter::backward_plan
protected

plans for fftw transform ops

Definition at line 150 of file OSFilter.hxx.

Referenced by apply(), and setupFFT().

◆ fft_input

std::complex<float>* SoDa::OSFilter::fft_input
protected

a copy of the input stream.

Definition at line 141 of file OSFilter.hxx.

Referenced by apply(), and setupFFT().

◆ fft_output

std::complex<float>* SoDa::OSFilter::fft_output
protected

the transformed input stream + overlap

Definition at line 142 of file OSFilter.hxx.

Referenced by apply(), and setupFFT().

◆ filter_fft

std::complex<float>* SoDa::OSFilter::filter_fft
protected

FFT image of the input filter.

Definition at line 146 of file OSFilter.hxx.

Referenced by apply(), dump(), ipow(), and OSFilter().

◆ forward_plan

fftwf_plan SoDa::OSFilter::forward_plan
protected

Definition at line 150 of file OSFilter.hxx.

Referenced by apply(), and setupFFT().

◆ high_edge

double SoDa::OSFilter::high_edge
protected

Definition at line 123 of file OSFilter.hxx.

Referenced by getFilterEdges(), and OSFilter().

◆ ifft_output

std::complex<float>* SoDa::OSFilter::ifft_output
protected

the output stream + overlap discard

Definition at line 143 of file OSFilter.hxx.

Referenced by apply(), and setupFFT().

◆ low_edge

double SoDa::OSFilter::low_edge
protected

parameters that we keep to support display masks on the spectrogram

Definition at line 123 of file OSFilter.hxx.

Referenced by getFilterEdges(), and OSFilter().

◆ M

unsigned int SoDa::OSFilter::M
protected

the input buffer length;

Definition at line 133 of file OSFilter.hxx.

Referenced by apply(), guessN(), ipow(), and OSFilter().

◆ N

unsigned int SoDa::OSFilter::N
protected

the total length of the transform N > (M + Q-1)

Definition at line 135 of file OSFilter.hxx.

Referenced by apply(), dump(), ipow(), OSFilter(), and setupFFT().

◆ Q

unsigned int SoDa::OSFilter::Q
protected

the filter length

Definition at line 134 of file OSFilter.hxx.

Referenced by apply(), guessN(), ipow(), OSFilter(), and setupFFT().

◆ tail_index

unsigned int SoDa::OSFilter::tail_index
protected

the beginning of the end.

Definition at line 138 of file OSFilter.hxx.

Referenced by apply(), ipow(), and OSFilter().


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