2024-06-16 09:31:13 +00: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
|
|
|
|
|
|
|
|
#include "export.h"
|
|
|
|
|
|
|
|
namespace WDSP {
|
|
|
|
|
|
|
|
class FIRCORE;
|
|
|
|
class RXA;
|
|
|
|
|
|
|
|
class WDSP_API NOTCHDB
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int master_run;
|
2024-06-25 01:50:48 +00:00
|
|
|
float tunefreq;
|
|
|
|
float shift;
|
2024-06-16 09:31:13 +00:00
|
|
|
int nn;
|
|
|
|
int* active;
|
2024-06-25 01:50:48 +00:00
|
|
|
float* fcenter;
|
|
|
|
float* fwidth;
|
|
|
|
float* nlow;
|
|
|
|
float* nhigh;
|
2024-06-16 09:31:13 +00:00
|
|
|
int maxnotches;
|
|
|
|
|
|
|
|
static NOTCHDB* create_notchdb (int master_run, int maxnotches);
|
|
|
|
static void destroy_notchdb (NOTCHDB *b);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
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-06-25 01:50:48 +00:00
|
|
|
float* in; // input buffer
|
|
|
|
float* out; // output buffer
|
|
|
|
float flow; // low bandpass cutoff freq
|
|
|
|
float fhigh; // high bandpass cutoff freq
|
|
|
|
float* impulse; // filter impulse response
|
|
|
|
float rate; // sample rate
|
2024-06-16 09:31:13 +00:00
|
|
|
int wintype; // filter window type
|
2024-06-25 01:50:48 +00:00
|
|
|
float gain; // filter gain
|
2024-06-16 09:31:13 +00:00
|
|
|
int autoincr; // auto-increment notch width
|
|
|
|
int maxpb; // maximum number of passbands
|
|
|
|
NOTCHDB* ptraddr; // ptr to addr of notch-database data structure
|
2024-06-25 01:50:48 +00:00
|
|
|
float* bplow; // array of passband lows
|
|
|
|
float* bphigh; // array of passband highs
|
2024-06-16 09:31:13 +00:00
|
|
|
int numpb; // number of passbands
|
|
|
|
FIRCORE *p;
|
|
|
|
int havnotch;
|
|
|
|
int hadnotch;
|
|
|
|
|
|
|
|
static NBP* create_nbp(
|
|
|
|
int run,
|
|
|
|
int fnfrun,
|
|
|
|
int position,
|
|
|
|
int size,
|
|
|
|
int nc,
|
|
|
|
int mp,
|
2024-06-25 01:50:48 +00:00
|
|
|
float* in,
|
|
|
|
float* out,
|
|
|
|
float flow,
|
|
|
|
float fhigh,
|
2024-06-16 09:31:13 +00:00
|
|
|
int rate,
|
|
|
|
int wintype,
|
2024-06-25 01:50:48 +00:00
|
|
|
float gain,
|
2024-06-16 09:31:13 +00:00
|
|
|
int autoincr,
|
|
|
|
int maxpb,
|
|
|
|
NOTCHDB* ptraddr
|
|
|
|
);
|
|
|
|
static void destroy_nbp (NBP *a);
|
|
|
|
static void flush_nbp (NBP *a);
|
|
|
|
static void xnbp (NBP *a, int pos);
|
2024-06-25 01:50:48 +00:00
|
|
|
static void setBuffers_nbp (NBP *a, float* in, float* out);
|
2024-06-16 09:31:13 +00:00
|
|
|
static void setSamplerate_nbp (NBP *a, int rate);
|
|
|
|
static void setSize_nbp (NBP *a, int size);
|
|
|
|
static void calc_nbp_impulse (NBP *a);
|
|
|
|
static void setNc_nbp (NBP *a);
|
|
|
|
static void setMp_nbp (NBP *a);
|
|
|
|
// RXA Properties
|
|
|
|
static void UpdateNBPFiltersLightWeight (RXA& rxa);
|
|
|
|
static void UpdateNBPFilters(RXA& rxa);
|
2024-06-25 01:50:48 +00:00
|
|
|
static int NBPAddNotch (RXA& rxa, int notch, float fcenter, float fwidth, int active);
|
|
|
|
static int NBPGetNotch (RXA& rxa, int notch, float* fcenter, float* fwidth, int* active);
|
2024-06-16 09:31:13 +00:00
|
|
|
static int NBPDeleteNotch (RXA& rxa, int notch);
|
2024-06-25 01:50:48 +00:00
|
|
|
static int NBPEditNotch (RXA& rxa, int notch, float fcenter, float fwidth, int active);
|
2024-06-16 09:31:13 +00:00
|
|
|
static void NBPGetNumNotches (RXA& rxa, int* nnotches);
|
2024-06-25 01:50:48 +00:00
|
|
|
static void NBPSetTuneFrequency (RXA& rxa, float tunefreq);
|
|
|
|
static void NBPSetShiftFrequency (RXA& rxa, float shift);
|
2024-06-16 09:31:13 +00:00
|
|
|
static void NBPSetNotchesRun (RXA& rxa, int run);
|
|
|
|
static void NBPSetRun (RXA& rxa, int run);
|
2024-06-25 01:50:48 +00:00
|
|
|
static void NBPSetFreqs (RXA& rxa, float flow, float fhigh);
|
2024-06-16 09:31:13 +00:00
|
|
|
static void NBPSetWindow (RXA& rxa, int wintype);
|
|
|
|
|
|
|
|
static void NBPSetNC (RXA& rxa, int nc);
|
|
|
|
static void NBPSetMP (RXA& rxa, int mp);
|
|
|
|
|
2024-06-25 01:50:48 +00:00
|
|
|
static void NBPGetMinNotchWidth (RXA& rxa, float* minwidth);
|
2024-06-16 09:31:13 +00:00
|
|
|
static void NBPSetAutoIncrease (RXA& rxa, int autoincr);
|
|
|
|
|
|
|
|
private:
|
2024-06-25 01:50:48 +00:00
|
|
|
static float* fir_mbandpass (int N, int nbp, float* flow, float* fhigh, float rate, float scale, int wintype);
|
|
|
|
static float min_notch_width (NBP *a);
|
2024-06-16 09:31:13 +00:00
|
|
|
static int make_nbp (
|
|
|
|
int nn,
|
|
|
|
int* active,
|
2024-06-25 01:50:48 +00:00
|
|
|
float* center,
|
|
|
|
float* width,
|
|
|
|
float* nlow,
|
|
|
|
float* nhigh,
|
|
|
|
float minwidth,
|
2024-06-16 09:31:13 +00:00
|
|
|
int autoincr,
|
2024-06-25 01:50:48 +00:00
|
|
|
float flow,
|
|
|
|
float fhigh,
|
|
|
|
float* bplow,
|
|
|
|
float* bphigh,
|
2024-06-16 09:31:13 +00:00
|
|
|
int* havnotch
|
|
|
|
);
|
|
|
|
static void calc_nbp_lightweight (NBP *a);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace WDSP
|
|
|
|
|
|
|
|
#endif
|