JS8Call-Improved master
Loading...
Searching...
No Matches
Modulator.h
Go to the documentation of this file.
1
5
6#ifndef MODULATOR_HPP__
7#define MODULATOR_HPP__
8
10
11#include <QAudio>
12#include <QPointer>
13
14class SoundOutput;
15
26class Modulator final : public AudioDevice {
27 Q_OBJECT;
28
29 public:
30 enum class State { Synchronizing, Active, Idle };
31
36 explicit Modulator(QObject *parent = nullptr) : AudioDevice{parent} {}
37
44 bool isIdle() const { return m_state.load() == State::Idle; }
45
46 // Manipulators
47
51 void close() override;
52
59 Q_SLOT void setAudioFrequency(double const audioFrequency) {
60 m_audioFrequency = audioFrequency;
61 }
62
63 // Slots
64
68 Q_SLOT void start(double audioFrequency, int submode, double tx_delay,
69 SoundOutput *stream, Channel channel);
70
75 Q_SLOT void stop(bool quick = false);
76
80 Q_SLOT void tune(bool state = true);
81
82 protected:
83 // QIODevice protocol
84
85 qint64 readData(char *, qint64) override;
86 qint64 writeData(char const *, qint64) override { return -1; }
87
104 qint64 bytesAvailable() const override { return 8000; }
105
106 private:
107 // Data members
108
109 QPointer<SoundOutput> m_stream;
110 std::atomic<State> m_state = State::Idle;
111 bool m_quickClose = false;
112 bool m_tuning = false;
113 double m_audioFrequency;
114 double m_audioFrequency0;
115 double m_toneSpacing;
116 double m_phi;
117 double m_dphi;
118 double m_amp;
119 double m_nsps;
120 qint64 m_silentFrames;
121 unsigned m_ic;
122 unsigned m_isym0;
123};
124
125#endif
Audio Device declarations for JS8Call-improved.
Channel channel() const
Get the current channel selection used by this device.
Definition AudioDevice.h:109
Channel
Audio channel selection used by the device.
Definition AudioDevice.h:35
qint64 readData(char *, qint64) override
Read data from the modulator.
Definition Modulator.cpp:178
Q_SLOT void tune(bool state=true)
Enter or leave tuning state.
Definition Modulator.cpp:139
Q_SLOT void start(double audioFrequency, int submode, double tx_delay, SoundOutput *stream, Channel channel)
Start transmission with the given parameters.
Definition Modulator.cpp:38
Q_SLOT void setAudioFrequency(double const audioFrequency)
Set the base audio frequency used for modulation.
Definition Modulator.h:59
void close() override
Close the device and stop generating samples.
Definition Modulator.cpp:159
qint64 bytesAvailable() const override
Bytes available hint for QAudioSink; ensures Active state.
Definition Modulator.h:104
Modulator(QObject *parent=nullptr)
Construct a modulator instance.
Definition Modulator.h:36
bool isIdle() const
Whether the device is currently idle.
Definition Modulator.h:44
Q_SLOT void stop(bool quick=false)
Stop transmission.
Definition Modulator.cpp:150
Manages audio output format, buffering and the underlying sink.
Definition SoundOutput.h:24