-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdemodulator.hpp
50 lines (36 loc) · 970 Bytes
/
demodulator.hpp
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
#pragma once
#include <array>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <deque>
#include <memory>
#include <vector>
#include "costas.hpp"
#include "gardner.hpp"
namespace kvak {
class demodulator {
public:
demodulator();
std::optional<std::uint8_t> push_sample(std::complex<float> sample);
float get_timing_offset();
float get_frequency_offset();
private:
void shift_delay_line(std::complex<float> sample);
void resample();
std::uint8_t calculate_output();
// How many samples are we forward by at the moment
kvak::costas costas;
kvak::gardner gardner;
// Stores the recent input samples, twice to allow easy pointer-ing
// (trick from gnuradio)
std::vector<std::complex<float>> delay_line;
unsigned int delay_line_i;
// Storage for (resampled) sample history
std::complex<float> sample_prev_prev;
std::complex<float> sample_prev;
std::complex<float> sample_now;
bool at_midpoint;
};
};