~ubuntu-branches/ubuntu/quantal/linpsk/quantal

« back to all changes in this revision

Viewing changes to linpsk/rttydemodulator.h

  • Committer: Bazaar Package Importer
  • Author(s): Bruce Walker
  • Date: 2002-02-06 11:43:38 UTC
  • Revision ID: james.westby@ubuntu.com-20020206114338-xqmjmhh01lpjm0g4
Tags: upstream-0.6.2
ImportĀ upstreamĀ versionĀ 0.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          rttydemodulator.h  -  description
 
3
                             -------------------
 
4
    begin                : Mon Jun 4 2001
 
5
    copyright            : (C) 2001 by Volker Schroer
 
6
    email                : dl1ksv@gmx.de
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
11
 *   This program 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 2 of the License, or     *
 
14
 *   (at your option) any later version.                                   *
 
15
 ***************************************************************************/
 
16
 
 
17
#ifndef RTTYDEMODULATOR_H
 
18
#define RTTYDEMODULATOR_H
 
19
 
 
20
#include <cdemodulator.h>
 
21
#include <complex.h>
 
22
 
 
23
/**Decodes RTTY 
 
24
  *@author Volker Schroer
 
25
  */
 
26
enum StateOfReception { WaitingForMark,WaitingForSpace, CheckingStartBit,SkipRestOfStartBit,CollectingByte,
 
27
                                                                                                 CheckingParity, WaitingForStopBits,ThrowHalfBit};
 
28
/** Number of tones used in fsk (2 for Rtty) but we use 7 for doing some afc */
 
29
 
 
30
#define  NumberofTones 7
 
31
 
 
32
class RTTYDemodulator : public CDemodulator  {
 
33
public: 
 
34
        RTTYDemodulator();
 
35
        ~RTTYDemodulator();
 
36
 
 
37
        /** Prozess the input */
 
38
        void ProcessInput(double * input);
 
39
        
 
40
        bool Init(double,int);
 
41
        
 
42
public slots: // Public slots
 
43
/** Set RxFrequencies for RTTY */
 
44
void setRxFrequency(double);
 
45
 
 
46
private:        //Private Variables
 
47
 
 
48
/** coeficients for slidding fft */
 
49
float_complex *twiddles;
 
50
 
 
51
/** result of slidding fft for the different tones */
 
52
float_complex *bins;
 
53
/** history of sampled values for fft */
 
54
float *history;
 
55
/** Mapping of Frequency to integer number (index) */
 
56
int *FrequencyNumber;
 
57
 
 
58
/** Number of samples to process */
 
59
int NxSamples;
 
60
/** Actuell Sample , just to be processed */
 
61
int actSample;
 
62
/** Adress of data */
 
63
double *data;
 
64
 
 
65
/** SampleRate */
 
66
double SampleRate;
 
67
 
 
68
/** Status of Shift */
 
69
bool ShiftOn;
 
70
 
 
71
/** Baudrate */
 
72
int Baudrate;
 
73
/** Number of Stopbits */
 
74
 
 
75
unsigned int NumberOfStopBits;
 
76
 
 
77
/** Parity
 
78
        0 none
 
79
        1 even
 
80
        2 odd   */
 
81
unsigned int parity;
 
82
/** Samples per bit */
 
83
unsigned int SamplesPerBit;
 
84
/** Number of Bits per Character */
 
85
unsigned int NumberOfBits;
 
86
 
 
87
bool DataAvailable;
 
88
 
 
89
/** Status of reception*/
 
90
StateOfReception Status;
 
91
 
 
92
/** Pointer to history */
 
93
int ptr;
 
94
 
 
95
/** Counts the number of bits in act. Character ( for parity) */
 
96
unsigned int BitsInData;
 
97
/** Number of Bits to be processed */
 
98
int bitcounter ;
 
99
/** Bitpattern of actual processed byte */
 
100
int c;
 
101
/** has detected Frequency changed ? */
 
102
bool FrequencyChanged;
 
103
/** How to correct the Rxfrequency */
 
104
int Frequencykor;
 
105
/** previous sample */
 
106
int x1;
 
107
/** Sample position in bit */
 
108
unsigned int count ;
 
109
/** Variables for Squelch computing */
 
110
float ave1,ave2;
 
111
 
 
112
 
 
113
private: // Private methods
 
114
  /** returns the asci char coresponding to the baudot code */
 
115
  char baudot_code(char);
 
116
  /** Processes the next sample */
 
117
  int ProcessNextSample();
 
118
  /** gets the next bit */
 
119
  bool get_next_bit();
 
120
        /** Sliding fft */
 
121
        void slfft(float);
 
122
        /** Calc the quality of the signal for squelch */
 
123
        void CalcQuality();
 
124
        /** Reset the values of sliding of fft */
 
125
        void reset();
 
126
};
 
127
 
 
128
#endif