-
Notifications
You must be signed in to change notification settings - Fork 3
/
SDRunoPlugin_rtty.h
160 lines (150 loc) · 4.77 KB
/
SDRunoPlugin_rtty.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#pragma once
#include <thread>
#include <mutex>
#include <atomic>
#include <iunoplugincontroller.h>
#include <iunoplugin.h>
#include <iunostreamobserver.h>
#include <iunoaudioobserver.h>
//#include <iunoaudioprocessor.h>
#include <iunostreamobserver.h>
#include <iunoannotator.h>
//
#include "SDRunoPlugin_rttyUi.h"
//
// for the payload we have
class upFilter;
#include "ringbuffer.h"
#include <stdint.h>
#include "rtty-shifter.h"
#include "decimator-25.h"
#include "rtty-bandfilter.h"
class rttyAverage;
/*
* defines, local for the rttyDetector stuff
*/
#define RTTY_RX_STATE_IDLE 0
#define RTTY_RX_STATE_START 1
#define RTTY_RX_STATE_DATA 2
#define RTTY_RX_STATE_PARITY 3
#define RTTY_RX_STATE_STOP 4
#define RTTY_RX_STATE_STOP2 5
#define BAUDOT_LETS 0
#define BAUDOT_FIGS 1
#define RTTY_IF 0
#define DECIMATOR 5
#define INRATE 192000
#define WORKING_RATE 12000
class SDRunoPlugin_rtty : public IUnoPlugin,
public IUnoStreamProcessor,
public IUnoAudioProcessor {
public:
SDRunoPlugin_rtty (IUnoPluginController& controller);
virtual ~SDRunoPlugin_rtty ();
virtual const
char* GetPluginName() const override { return "rtty decoder"; }
virtual
void StreamProcessorProcess (channel_t channel,
Complex *buffer,
int length,
bool& modified) override;
virtual
void AudioProcessorProcess (channel_t channel,
float *buffer,
int length, bool& modified) override;
// IUnoPlugin
virtual
void HandleEvent(const UnoEvent& ev) override;
void set_rttyAfcon (const std::string&);
void set_rttyReverse (const std::string&);
void set_rttyShift (const std::string&);
void set_rttyBaudrate (const std::string&);
void set_rttyParity (const std::string&);
void set_rttyMsb (const std::string&);
void set_rttyNbits (const std::string&);
void set_rttyStopbits (const std::string&);
enum Parities {
RTTY_PARITY_NONE = 0,
RTTY_PARITY_EVEN = 1,
RTTY_PARITY_ODD = 2,
RTTY_PARITY_ZERO = 3,
RTTY_PARITY_ONE = 4
};
private:
std::mutex m_lock;
SDRunoPlugin_rttyUi m_form;
std::mutex locker;
IUnoPluginController *m_controller;
RingBuffer<Complex> rttyBuffer;
// rttyShifter theMixer;
rttyBandfilter passbandFilter;
decimator_25 theDecimator;
//rttyShifter localShifter;
RingBuffer<float> rttyAudioBuffer;
std::vector<std::complex<float>> rttyToneBuffer;
int rttyTonePhase;
int SDRplay_Rate;
bool rttyError;
void WorkerFunction ();
void processSample (std::complex <float>);
void rtty_setup ();
std::thread* m_worker;
std::atomic<bool> running;
int centerFrequency;
int selectedFrequency;
void rtty_setReverse (bool);
uint32_t reverseBits (uint32_t, uint32_t);
unsigned char pickup_char (void);
uint8_t check_parity (uint32_t,
uint32_t, unsigned char);
uint8_t odd (uint32_t);
void check_baudrate (int16_t, int16_t);
double adjust_IF (double);
unsigned char addrttyBitFragment (void);
unsigned char BaudottoASCII (unsigned char);
double rttyS2N (void);
rttyAverage *rttyAverager;
int16_t rttyCycleCount;
unsigned char rttyBitFragment;
int16_t rttyPoscnt;
int16_t rttyNegcnt;
double rttyPosFreq;
double rttyNegFreq;
double rttyFreqError;
std::complex<float> rttyPrevsample;
rttyBandfilter *BPM_Filter;
upFilter *audioFilter;
int rttyAudioRate;
bool rttyAfcon;
double rttyShift;
double rttyIF;
int16_t rttySymbolLength;
int16_t rttyNbits;
unsigned char rttyParity;
int16_t rttyStopbits;
bool rttyMsb;
int16_t rttyStoplen;
bool rttyReversed;
int16_t rttyFilterDegree;
int16_t rttyPhaseacc;
int16_t rttyState;
int16_t rttyCounter;
int16_t rttyBitcntr;
int16_t rttyRxdata;
unsigned char rttyRxmode;
double rttyBaudrate;
int16_t rttyPluscnt;
int16_t rttyMincnt;
int16_t rttyPrevfragment;
std::string rttyText;
double rttySignalPower;
double rttyNoisePower;
//
// former signals, now handled locally
void rtty_showIF (float);
void rtty_showFreqCorrection (float);
void rtty_showBaudRate (int);
void rtty_showGuess (int);
void rtty_clrText ();
void rtty_addText (char);
};