1 // ---------------------------------------------------------------------------- 2 // throb.h -- BASIS FOR ALL MODEMS 3 // 4 // Copyright (C) 2006-2007 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 _THROB_H 24 #define _THROB_H 25 26 #include "modem.h" 27 #include "globals.h" 28 #include "fftfilt.h" 29 #include "filters.h" 30 #include "complex.h" 31 32 #include "mbuffer.h" 33 34 #define THROB_SAMPLE_RATE 8000 35 #define SYMLEN 512 36 37 #define BUFFLEN 4096 38 #define SCOPE_DATA_LEN 1024 39 40 #define DOWN_SAMPLE 32 41 42 #define SYMLEN_1 8192 43 #define SYMLEN_2 4096 44 #define SYMLEN_4 2048 45 46 #define MAX_RX_SYMLEN (SYMLEN_1 / DOWN_SAMPLE) 47 48 #define FilterFFTLen 8192 49 50 class throb : public modem { 51 52 static double ThrobToneFreqsNar[]; 53 static double ThrobToneFreqsWid[]; 54 static double ThrobXToneFreqsNar[]; 55 static double ThrobXToneFreqsWid[]; 56 static unsigned char ThrobCharSet[]; 57 static unsigned char ThrobXCharSet[]; 58 static int ThrobTonePairs[][2]; 59 static int ThrobXTonePairs[][2]; 60 61 protected: 62 63 int num_tones; 64 int num_chars; 65 int idlesym; 66 int spacesym; 67 char lastchar; 68 69 double phaseacc; 70 double phaseincr; 71 72 fftfilt *fftfilter; 73 C_FIR_filter *syncfilt; 74 C_FIR_filter *hilbert; 75 Cmovavg *snfilter; 76 77 int symlen; 78 double freqs[55]; 79 80 // receive 81 double *scope_data; 82 cmplx *rxtone[55]; 83 cmplx symbol[MAX_RX_SYMLEN]; 84 85 double syncbuf[MAX_RX_SYMLEN]; 86 mbuffer<double, MAX_RX_SYMLEN, 2> dispbuf; 87 88 double rxcntr; 89 double signal; 90 double noise; 91 92 double s2n; 93 94 int rxsymlen; 95 int symptr; 96 int deccntr; 97 int shift; 98 int waitsync; 99 100 cmplx mixer(cmplx in); 101 void sync(cmplx in); 102 void rx(cmplx in); 103 void decodechar(int tone1, int tone2); 104 int findtones(cmplx *word, int &tone1, int &tone2); 105 cmplx *mk_rxtone(double freq, double *pulse, int len); 106 void show_char(int); 107 void flip_syms(); 108 void reset_syms(); 109 110 111 // transmit 112 int txstate; 113 114 int preamble; 115 double *txpulse; 116 117 double *outbuf; 118 unsigned int buffptr; 119 120 double *mk_semi_pulse(int len); 121 double *mk_full_pulse(int len); 122 void send(int); 123 124 public: 125 throb(trx_mode); 126 ~throb(); 127 void init(); 128 void rx_init(); 129 void tx_init(); restart()130 void restart() {}; 131 int rx_process(const double *buf, int len); 132 int tx_process(); 133 void update_syncscope(); 134 135 }; 136 137 #endif 138