1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-11 02:46:12 -05:00
sdrangel/wdsp/nbp.hpp

148 lines
3.9 KiB
C++

/* nbp.h
This file is part of a program that implements a Software-Defined Radio.
Copyright (C) 2015, 2016 Warren Pratt, NR0V
Copyright (C) 2024 Edouard Griffiths, F4EXB Adapted to SDRangel
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached by email at
warren@wpratt.com
*/
#ifndef wdsp_nbp_h
#define wdsp_nbp_h
#include "export.h"
namespace WDSP {
class FIRCORE;
class WDSP_API NOTCHDB
{
public:
int master_run;
double tunefreq;
double shift;
int nn;
int* active;
double* fcenter;
double* fwidth;
double* nlow;
double* nhigh;
int maxnotches;
NOTCHDB(int master_run, int maxnotches);
~NOTCHDB();
int addNotch (int notch, double fcenter, double fwidth, int active);
int getNotch (int notch, double* fcenter, double* fwidth, int* active);
int deleteNotch (int notch);
int editNotch (int notch, double fcenter, double fwidth, int active);
void getNumNotches (int* nnotches);
};
class NBP
{
public:
int run; // run the filter
int fnfrun; // use the notches
int position; // position in processing pipeline
int size; // buffer size
int nc; // number of filter coefficients
int mp; // minimum phase flag
double rate; // sample rate
int wintype; // filter window type
double gain; // filter gain
float* in; // input buffer
float* out; // output buffer
int autoincr; // auto-increment notch width
double flow; // low bandpass cutoff freq
double fhigh; // high bandpass cutoff freq
float* impulse; // filter impulse response
int maxpb; // maximum number of passbands
NOTCHDB* notchdb; // ptr to addr of notch-database data structure
double* bplow; // array of passband lows
double* bphigh; // array of passband highs
int numpb; // number of passbands
FIRCORE *fircore;
int havnotch;
int hadnotch;
NBP(
int run,
int fnfrun,
int position,
int size,
int nc,
int mp,
float* in,
float* out,
double flow,
double fhigh,
int rate,
int wintype,
double gain,
int autoincr,
int maxpb,
NOTCHDB* notchdb
);
~NBP();
void flush();
void execute(int pos);
void setBuffers(float* in, float* out);
void setSamplerate(int rate);
void setSize(int size);
void calc_impulse();
void setNc();
void setMp();
// public Properties
void SetRun(int run);
void SetFreqs(double flow, double fhigh);
void SetNC(int nc);
void SetMP(int mp);
void GetMinNotchWidth(double* minwidth);
void calc_lightweight();
private:
static float* fir_mbandpass (int N, int nbp, double* flow, double* fhigh, double rate, double scale, int wintype);
double min_notch_width ();
static int make_nbp (
int nn,
int* active,
double* center,
double* width,
double* nlow,
double* nhigh,
double minwidth,
int autoincr,
double flow,
double fhigh,
double* bplow,
double* bphigh,
int* havnotch
);
};
} // namespace WDSP
#endif