1 // ----------------------------------------------------------------------------
2 // contestia.h
3 //
4 // Copyright (C) 2006-2010
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 _CONTESTIA_H
24 #define _CONTESTIA_H
25 
26 #include "modem.h"
27 #include "jalocha/pj_mfsk.h"
28 #include "sound.h"
29 
30 #define TONE_DURATION (SCBLOCKSIZE * 16)
31 #define SR4 ((TONE_DURATION) / 4)
32 
33 class contestia : public modem {
34 private:
35 
36 	MFSK_Transmitter < double >*Tx;
37 	MFSK_Receiver < double >*Rx;
38 
39 	double		*txfbuffer;
40 	int 		txbufferlen;
41 
42 	double		phaseacc;
43 	cmplx		prevsymbol;
44 	int			preamble;
45 	unsigned int	shreg;
46 
47 	double		np;
48 	double		sp;
49 	double		sigpwr;
50 	double		noisepwr;
51 
52 	int			escape;
53 	int			smargin;
54 	int			sinteg;
55 	int			tones;
56 	int			bw;
57 	double		tone_bw;
58 
59 	int			preamblesent;
60 	int			postamblesent;
61 	double		preamblephase;
62 
63 	double		txbasefreq;
64 	double		tone_midfreq;
65 	double		lastfreq;
66 
67 	double		ampshape[SR4];
68 	double		tonebuff[TONE_DURATION];
69 
70 	double		nco(double freq);
71 	void		send_tones();
72 
73 public:
74 	contestia(trx_mode omode = MODE_CONTESTIA);
75 	~contestia();
76 	void init();
77 	void rx_init();
78 	void rx_flush();
79 	void tx_init();
80 	void restart();
81 	int rx_process(const double *buf, int len);
82 	int tx_process();
83 	int unescape(int c);
84 };
85 
86 
87 #endif
88