1 // ---------------------------------------------------------------------------- 2 // dominoex.h -- DominoEX modem 3 // 4 // Copyright (C) 2001, 2002, 2003 5 // Tomi Manninen (oh2bns@sral.fi) 6 // Copyright (C) 2006 7 // Hamish Moffatt (hamish@debian.org) 8 // Copyright (C) 2006 9 // David Freese (w1hkj@w1hkj.com) 10 // 11 // Fldigi is free software: you can redistribute it and/or modify 12 // it under the terms of the GNU General Public License as published by 13 // the Free Software Foundation, either version 3 of the License, or 14 // (at your option) any later version. 15 // 16 // Fldigi is distributed in the hope that it will be useful, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 // GNU General Public License for more details. 20 // 21 // You should have received a copy of the GNU General Public License 22 // along with fldigi. If not, see <http://www.gnu.org/licenses/>. 23 // ---------------------------------------------------------------------------- 24 25 #ifndef _DOMINOEX_H 26 #define _DOMINOEX_H 27 28 #include <string> 29 30 #include "complex.h" 31 #include "modem.h" 32 #include "filters.h" 33 #include "fftfilt.h" 34 #include "dominovar.h" 35 #include "mbuffer.h" 36 37 // NASA coefficients for viterbi encode/decode algorithms 38 #define NASA_K 7 39 #define POLY1 0x6d 40 #define POLY2 0x4f 41 42 //#include "mfskvaricode.h" 43 #include "interleave.h" 44 #include "viterbi.h" 45 46 #define NUMTONES 18 47 #define MAXFFTS 8 48 #define BASEFREQ 1000.0 49 #define FIRSTIF 1500.0 50 51 #define SCOPESIZE 64 52 53 struct domrxpipe { 54 cmplx vector[MAXFFTS * NUMTONES * 6]; 55 }; 56 57 class dominoex : public modem { 58 public: 59 enum { 60 TX_STATE_PREAMBLE, 61 TX_STATE_START, 62 TX_STATE_DATA, 63 TX_STATE_END, 64 TX_STATE_FLUSH 65 }; 66 protected: 67 // common variables 68 double phase[MAXFFTS + 1]; 69 double txphase; 70 int symlen; 71 int doublespaced; 72 double tonespacing; 73 int counter; 74 unsigned int twosym; 75 int paths; 76 int numbins; 77 bool slowcpu; 78 int basetone; 79 int lotone; 80 int hitone; 81 int extones; 82 83 // rx variables 84 C_FIR_filter *hilbert; 85 sfft *binsfft[MAXFFTS]; 86 fftfilt *fft; 87 Cmovavg *vidfilter[SCOPESIZE]; 88 Cmovavg *syncfilter; 89 90 domrxpipe *pipe; 91 unsigned int pipeptr; 92 mbuffer<double, 0, 2> scopedata; 93 mbuffer<double, 0, 2> videodata; 94 95 cmplx currvector; 96 97 int currsymbol; 98 int prev1symbol; 99 int prev2symbol; 100 101 double met1; 102 double met2; 103 double sig; 104 double noise; 105 double s2n; 106 107 int synccounter; 108 109 unsigned char symbolbuf[MAX_VARICODE_LEN]; 110 int symcounter; 111 112 int symbolbit; 113 114 bool filter_reset; 115 bool staticburst; 116 bool outofrange; 117 118 // tx variables 119 int txstate; 120 int txprevtone; 121 unsigned int bitshreg; 122 std::string strSecXmtText; 123 124 // FEC variables 125 viterbi *MuPskDec; 126 interleave *MuPskRxinlv; 127 encoder *MuPskEnc; 128 interleave *MuPskTxinlv; 129 int Mu_bitstate; 130 unsigned char Mu_symbolpair[2]; 131 unsigned int Mu_datashreg; 132 int Mu_symcounter; 133 134 private: 135 cmplx mixer(int n, cmplx in); 136 void recvchar(int c); 137 void decodesymbol(); 138 void decodeDomino(int c); 139 int harddecode(); 140 void update_syncscope(); 141 void synchronize(); 142 void afc(); 143 void reset_afc(); 144 void eval_s2n(); 145 void sendtone(int tone, int duration); 146 void sendsymbol(int sym); 147 void sendchar(unsigned char c, int secondary); 148 void sendidle(); 149 void sendsecondary(); 150 void flushtx(); 151 int get_secondary_char(); 152 void reset_filters(); 153 // MultiPsk FEC scheme 154 // Rx 155 unsigned int MuPskPriSecChar(unsigned int c); 156 void decodeMuPskSymbol(unsigned char symbol); 157 void decodeMuPskEX(int c); 158 // Tx 159 unsigned char MuPskSec2Pri(int c); 160 void sendMuPskEX(unsigned char c, int secondary); 161 void MuPskClearbits(); 162 void MuPskFlushTx(); 163 void MuPsk_sec2pri_init(void); 164 public: 165 dominoex (trx_mode md); 166 ~dominoex (); 167 void init(); 168 void rx_init(); 169 void tx_init(); 170 void restart(); 171 int rx_process(const double *buf, int len); 172 int tx_process(); 173 }; 174 175 #endif 176