forked from paulh002/sdrberry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AMmodulator.h
65 lines (59 loc) · 1.61 KB
/
AMmodulator.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
#pragma once
#include <cstdio>
#include <cassert>
#include <cmath>
#include <complex>
#include <liquid.h>
#include <vector>
#include "DataBuffer.h"
#include "AudioOutput.h"
#include "AudioInput.h"
#include "sdrberry.h"
struct modulator_struct
{
int tone;
double ifrate;
double tuner_offset;
liquid_ampmodem_type mode;
int suppressed_carrier;
int pcmrate;
double bandwidth_pcm;
unsigned int downsample;
DataBuffer<IQSample16> *source_buffer;
AudioInput *audio_input;
};
class AMmodulator
{
public:
void init(modulator_struct * ptr);
void tone(bool tone);
void set_filter(double if_rate, int band_width);
void process(const SampleVector& samples, double if_rate, DataBuffer<IQSample16> *source_buffer);
double get_if_level() const
{
return m_if_level;
}
void am_exit();
void createBandpass(int txfilter);
void tune_offset(long offset);
private:
mutex m_mutex; // used to lock the process for changing filters
ampmodem m_mod {0};
iirfilt_crcf m_lowpass {0};
int m_order {6};
bool m_bresample {false};
long m_resample;
msresamp_crcf m_q {0};
float m_r;
DataBuffer<IQSample16> *m_source_buffer = NULL;
double m_audio_mean, m_audio_rms, m_audio_level, m_if_level;
nco_crcf m_upssb {nullptr};
nco_crcf m_upnco {nullptr};
iirfilt_crcf m_au_lp_q { nullptr };
iirfilt_crcf m_tx_lp_q { nullptr };
long m_offset {0};
bool m_tone;
AudioInput *m_audio_input;
double m_ifrate;
};
void start_dsb_tx(int mode, double ifrate, int pcmrate, int tone, DataBuffer<IQSample16> *source_buffer, AudioInput *audio_input);