1 // ----------------------------------------------------------------------------
2 // wwv.h  --  wwv receive only modem
3 //
4 // Copyright (C) 2006
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 _wwv_H
24 #define _wwv_H
25 
26 //#include "complex.h"
27 #include "modem.h"
28 #include "filters.h"
29 #include "fftfilt.h"
30 #include "mbuffer.h"
31 
32 #define	wwvSampleRate	8000
33 #define	MaxSymLen	512
34 
35 // lp filter #1
36 //#define	DEC_1		40
37 #define DEC_1		8
38 #define FIRLEN_1	512
39 #define BW_1		20
40 // lp filter #2
41 #define DEC_2		5
42 #define	FIRLEN_2	256
43 #define BW_2		100
44 
45 // wwv function return status codes.
46 #define	wwv_SUCCESS		0
47 #define	wwv_ERROR		-1
48 
49 class wwv : public modem {
50 protected:
51 	double			phaseacc;
52 	double			phaseincr;
53 	int				smpl_ctr;		// sample counter for timing wwv rx
54 	double			agc;			// threshold for tick detection
55 
56 	C_FIR_filter	*hilbert;
57 	C_FIR_filter	*lpfilter;
58 	Cmovavg			*vidfilter;
59 
60 	mbuffer<double, 1000, 2>	buffer;	// storage for 1000 samples/sec video
61 	unsigned int	buffptr;
62 	int				sync;
63 	int				sync0;
64 	int				ticks;
65 	int				x1;
66 	int				y1;
67 	int				x2;
68 	int				y2;
69 	bool			calc;
70 	bool			zoom;
71 
72 	double	keyshape[32]; // 4 msec rise and fall time for pulse
73 	double	audio[400];
74 	double	quiet[400];
75 	double	play[400];
76 
77 	double nco(double freq);
78 	void makeshape();
79 	void makeaudio();
80 
81 public:
82 	wwv();
83 	~wwv();
84 	void	init();
85 	void	rx_init();
86 	void	tx_init();
restart()87 	void 	restart() {};
88 	int		rx_process(const double *buf, int len);
89 	int		tx_process();
90 	void	update_syncscope();
91 	void	set1(int x, int y);
92 	void	set2(int x, int y);
93 
94 };
95 
96 #endif
97