2024-06-16 05:31:13 -04:00
|
|
|
/* 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
|
|
|
|
|
2024-07-27 17:29:15 -04:00
|
|
|
#include <vector>
|
|
|
|
|
2024-06-16 05:31:13 -04:00
|
|
|
#include "export.h"
|
|
|
|
|
|
|
|
namespace WDSP {
|
|
|
|
|
|
|
|
class FIRCORE;
|
|
|
|
|
|
|
|
class WDSP_API NOTCHDB
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int master_run;
|
2024-07-16 18:40:00 -04:00
|
|
|
double tunefreq;
|
|
|
|
double shift;
|
2024-06-16 05:31:13 -04:00
|
|
|
int nn;
|
2024-07-27 17:29:15 -04:00
|
|
|
std::vector<int> active;
|
|
|
|
std::vector<double> fcenter;
|
|
|
|
std::vector<double> fwidth;
|
|
|
|
std::vector<double> nlow;
|
|
|
|
std::vector<double> nhigh;
|
2024-06-16 05:31:13 -04:00
|
|
|
int maxnotches;
|
|
|
|
|
2024-07-24 14:29:55 -04:00
|
|
|
NOTCHDB(int master_run, int maxnotches);
|
2024-07-27 17:29:15 -04:00
|
|
|
NOTCHDB(const NOTCHDB&) = delete;
|
2024-07-29 02:57:02 -04:00
|
|
|
NOTCHDB& operator=(const NOTCHDB& other) = delete;
|
2024-07-27 17:29:15 -04:00
|
|
|
~NOTCHDB() = default;
|
2024-07-24 14:29:55 -04:00
|
|
|
|
|
|
|
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);
|
2024-06-16 05:31:13 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2024-07-24 14:29:55 -04:00
|
|
|
double rate; // sample rate
|
|
|
|
int wintype; // filter window type
|
|
|
|
double gain; // filter gain
|
2024-07-16 18:40:00 -04:00
|
|
|
float* in; // input buffer
|
|
|
|
float* out; // output buffer
|
2024-07-24 14:29:55 -04:00
|
|
|
int autoincr; // auto-increment notch width
|
2024-07-16 18:40:00 -04:00
|
|
|
double flow; // low bandpass cutoff freq
|
|
|
|
double fhigh; // high bandpass cutoff freq
|
|
|
|
float* impulse; // filter impulse response
|
2024-06-16 05:31:13 -04:00
|
|
|
int maxpb; // maximum number of passbands
|
2024-07-24 14:29:55 -04:00
|
|
|
NOTCHDB* notchdb; // ptr to addr of notch-database data structure
|
2024-07-27 17:29:15 -04:00
|
|
|
std::vector<double> bplow; // array of passband lows
|
|
|
|
std::vector<double> bphigh; // array of passband highs
|
2024-06-16 05:31:13 -04:00
|
|
|
int numpb; // number of passbands
|
2024-07-24 14:29:55 -04:00
|
|
|
FIRCORE *fircore;
|
2024-06-16 05:31:13 -04:00
|
|
|
int havnotch;
|
|
|
|
int hadnotch;
|
|
|
|
|
2024-07-24 14:29:55 -04:00
|
|
|
NBP(
|
2024-06-16 05:31:13 -04:00
|
|
|
int run,
|
|
|
|
int fnfrun,
|
|
|
|
int position,
|
|
|
|
int size,
|
|
|
|
int nc,
|
|
|
|
int mp,
|
2024-06-24 21:50:48 -04:00
|
|
|
float* in,
|
|
|
|
float* out,
|
2024-07-16 18:40:00 -04:00
|
|
|
double flow,
|
|
|
|
double fhigh,
|
2024-06-16 05:31:13 -04:00
|
|
|
int rate,
|
|
|
|
int wintype,
|
2024-07-16 18:40:00 -04:00
|
|
|
double gain,
|
2024-06-16 05:31:13 -04:00
|
|
|
int autoincr,
|
|
|
|
int maxpb,
|
2024-07-24 14:29:55 -04:00
|
|
|
NOTCHDB* notchdb
|
2024-06-16 05:31:13 -04:00
|
|
|
);
|
2024-07-27 17:29:15 -04:00
|
|
|
NBP(const NBP&) = delete;
|
2024-07-29 02:57:02 -04:00
|
|
|
NBP& operator=(const NBP& other) = delete;
|
2024-07-24 14:29:55 -04:00
|
|
|
~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();
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
private:
|
2024-07-16 18:40:00 -04:00
|
|
|
static float* fir_mbandpass (int N, int nbp, double* flow, double* fhigh, double rate, double scale, int wintype);
|
2024-07-24 14:29:55 -04:00
|
|
|
double min_notch_width ();
|
2024-06-16 05:31:13 -04:00
|
|
|
static int make_nbp (
|
|
|
|
int nn,
|
2024-07-27 17:29:15 -04:00
|
|
|
std::vector<int>& active,
|
|
|
|
std::vector<double>& center,
|
|
|
|
std::vector<double>& width,
|
|
|
|
std::vector<double>& nlow,
|
|
|
|
std::vector<double>& nhigh,
|
2024-07-16 18:40:00 -04:00
|
|
|
double minwidth,
|
2024-06-16 05:31:13 -04:00
|
|
|
int autoincr,
|
2024-07-16 18:40:00 -04:00
|
|
|
double flow,
|
|
|
|
double fhigh,
|
2024-07-27 17:29:15 -04:00
|
|
|
std::vector<double>& bplow,
|
|
|
|
std::vector<double>& bphigh,
|
2024-06-16 05:31:13 -04:00
|
|
|
int* havnotch
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace WDSP
|
|
|
|
|
|
|
|
#endif
|