/* snb.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_snba_h #define wdsp_snba_h #include #include "export.h" namespace WDSP{ class RESAMPLE; class WDSP_API SNBA { public: int run; float* in; float* out; int inrate; int internalrate; int bsize; int xsize; int ovrlp; int incr; int iasize; int iainidx; int iaoutidx; std::vector inaccum; std::vector xbase; double* xaux; int nsamps; int oasize; int oainidx; int oaoutidx; int init_oaoutidx; std::vector outaccum; int resamprun; int isize; RESAMPLE *inresamp; RESAMPLE *outresamp; float* inbuff; float* outbuff; double out_low_cut; double out_high_cut; static const int MAXIMP = 256; struct Exec { int asize; std::vector a; std::vector v; std::vector detout; std::vector savex; std::vector xHout; std::vector unfixed; int npasses; Exec(int xsize, int _asize, int _npasses); void fluxh(); }; Exec exec; struct Det { double k1; double k2; int b; int pre; int post; std::vector vp; std::vector vpwr; Det( int xsize, double k1, double k2, int b, int pre, int post ); void flush(); }; Det sdet; struct Scan { double pmultmin; }; Scan scan; struct Wrk { int xHat_a1rows_max; int xHat_a2cols_max; std::vector xHat_r; std::vector xHat_ATAI; std::vector xHat_A1; std::vector xHat_A2; std::vector xHat_P1; std::vector xHat_P2; std::vector trI_y; std::vector trI_v; std::vector dR_z; std::vector asolve_r; std::vector asolve_z; Wrk( int xsize, int asize ); void flush(); }; Wrk wrk; SNBA( int run, float* in, float* out, int inrate, int internalrate, int bsize, int ovrlp, int xsize, int asize, int npasses, double k1, double k2, int b, int pre, int post, double pmultmin, double out_low_cut, double out_high_cut ); ~SNBA(); void flush(); void execute(); void setBuffers(float* in, float* out); void setSamplerate(int rate); void setSize(int size); // Public Properties void setOvrlp(int ovrlp); void setAsize(int size); void setNpasses(int npasses); void setK1(double k1); void setK2(double k2); void setBridge(int bridge); void setPresamps(int presamps); void setPostsamps(int postsamps); void setPmultmin(double pmultmin); void setOutputBandwidth(double flow, double fhigh); private: void calc(); void decalc(); static void ATAc0 (int n, int nr, std::vector& A, std::vector& r); static void multA1TA2(std::vector& a1, std::vector& a2, int m, int n, int q, std::vector& c); static void multXKE(std::vector& a, const double* xk, int m, int q, int p, std::vector& vout); static void multAv(std::vector& a, std::vector& v, int m, int q, std::vector& vout); static void xHat( int xusize, int asize, const double* xk, std::vector& a, std::vector& xout, std::vector& r, std::vector& ATAI, std::vector& A1, std::vector& A2, std::vector& P1, std::vector& P2, std::vector& trI_y, std::vector& trI_v, std::vector& dR_z ); static void invf(int xsize, int asize, std::vector& a, const double* x, std::vector& v); static int scanFrame( int xsize, int pval, double pmultmin, std::vector& det, std::array& bimp, std::array& limp, std::array& befimp, std::array& aftimp, std::array& p_opt, int* next ); void det(int asize, std::vector& v, std::vector& detout); void execFrame(double* x); }; } // namespace #endif