1 // ---------------------------------------------------------------------------- 2 // fftmon.h -- frequency fftmon modem 3 // 4 // Copyright (C) 2017 5 // Dave Freese, W1HKJ 6 // 7 // This file is part of fldigi. 8 // 9 // Fldigi is free software: you can redistribute it and/or modify 10 // it under the terms of the GNU General Public License as published by 11 // the Free Software Foundation, either version 3 of the License, or 12 // (at your option) any later version. 13 // 14 // Fldigi is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // You should have received a copy of the GNU General Public License 20 // along with fldigi. If not, see <http://www.gnu.org/licenses/>. 21 // ---------------------------------------------------------------------------- 22 23 #ifndef _fftmon_H 24 #define _fftmon_H 25 26 #include <stdio.h> 27 28 #include <string> 29 #include <ctime> 30 #include <complex> 31 32 #include "filters.h" 33 #include "fftfilt.h" 34 #include "modem.h" 35 #include "mbuffer.h" 36 #include "gfft.h" 37 38 extern void writeFile(); 39 40 class fftmon : public modem { 41 friend void toggle_scans(void *); 42 43 public: 44 #define fftmonFFT_LEN 8192 // approximately 1 sec of bpf'd audio stream 45 #define LENdiv2 4096 46 47 private: 48 49 double *fftbuff; 50 double *dftbuff; 51 double *buffer; 52 Cmovavg *fftfilt[LENdiv2]; 53 54 double bshape[fftmonFFT_LEN]; 55 56 int fftmon_sr; 57 58 g_fft<double> *scanfft; 59 60 bool scans_stable; 61 int numscans; 62 blackman(double x)63 inline double blackman(double x) { 64 return (0.42 - 0.50 * cos(2 * M_PI * x) + 0.08 * cos(4 * M_PI * x)); 65 } 66 void update_fftscope(); 67 68 public: 69 fftmon(); 70 ~fftmon(); 71 void init(); rx_init()72 void rx_init() {} tx_init()73 void tx_init() {} 74 void restart(); 75 76 int rx_process(const double *buf, int len); 77 tx_process()78 int tx_process() { return -1; } 79 80 }; 81 82 #endif 83