mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 21:58:38 -05:00
080f7ef1a2
Static storage variables that should have been class members are made so. This ensures that if they are used as initialization one time switches then they will operate correctly when their class instantiated more than once. This now happoens for most classes due to the configurations switching facility which destroys all windows and re-instantiates them. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6661 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
94 lines
2.3 KiB
C++
94 lines
2.3 KiB
C++
#ifndef MODULATOR_HPP__
|
|
#define MODULATOR_HPP__
|
|
|
|
#include <QAudio>
|
|
#include <QPointer>
|
|
|
|
#include "AudioDevice.hpp"
|
|
|
|
class SoundOutput;
|
|
|
|
//
|
|
// Input device that generates PCM audio frames that encode a message
|
|
// and an optional CW ID.
|
|
//
|
|
// Output can be muted while underway, preserving waveform timing when
|
|
// transmission is resumed.
|
|
//
|
|
class Modulator
|
|
: public AudioDevice
|
|
{
|
|
Q_OBJECT;
|
|
|
|
public:
|
|
enum ModulatorState {Synchronizing, Active, Idle};
|
|
|
|
Modulator (unsigned frameRate, unsigned periodLengthInSeconds, QObject * parent = nullptr);
|
|
|
|
void close () override;
|
|
|
|
bool isTuning () const {return m_tuning;}
|
|
double frequency () const {return m_frequency;}
|
|
bool isActive () const {return m_state != Idle;}
|
|
void setSpread(double s) {m_fSpread=s;}
|
|
void setPeriod(unsigned p) {m_period=p;}
|
|
|
|
Q_SLOT void start (unsigned symbolsLength, double framesPerSymbol, double frequency,
|
|
double toneSpacing, SoundOutput *, Channel = Mono,
|
|
bool synchronize = true, bool fastMode = false,
|
|
double dBSNR = 99., int TRperiod=60);
|
|
Q_SLOT void stop (bool quick = false);
|
|
Q_SLOT void tune (bool newState = true);
|
|
Q_SLOT void setFrequency (double newFrequency) {m_frequency = newFrequency;}
|
|
Q_SIGNAL void stateChanged (ModulatorState) const;
|
|
|
|
protected:
|
|
qint64 readData (char * data, qint64 maxSize) override;
|
|
qint64 writeData (char const * /* data */, qint64 /* maxSize */) override
|
|
{
|
|
return -1; // we don't consume data
|
|
}
|
|
|
|
private:
|
|
qint16 postProcessSample (qint16 sample) const;
|
|
|
|
QPointer<SoundOutput> m_stream;
|
|
bool m_quickClose;
|
|
|
|
unsigned m_symbolsLength;
|
|
|
|
static double constexpr m_twoPi = 2.0 * 3.141592653589793238462;
|
|
static unsigned constexpr m_nspd = 2048 + 512; // CW ID WPM factor = 22.5 WPM
|
|
|
|
double m_phi;
|
|
double m_dphi;
|
|
double m_amp;
|
|
double m_nsps;
|
|
double volatile m_frequency;
|
|
double m_frequency0;
|
|
double m_snr;
|
|
double m_fac;
|
|
double m_toneSpacing;
|
|
double m_fSpread;
|
|
|
|
qint64 m_silentFrames;
|
|
qint32 m_TRperiod;
|
|
qint16 m_ramp;
|
|
|
|
unsigned m_frameRate;
|
|
unsigned m_period;
|
|
ModulatorState volatile m_state;
|
|
|
|
bool volatile m_tuning;
|
|
bool m_addNoise;
|
|
bool m_bFastMode;
|
|
|
|
bool m_cwLevel;
|
|
unsigned m_ic;
|
|
unsigned m_isym0;
|
|
int m_j0;
|
|
double m_toneFrequency0;
|
|
};
|
|
|
|
#endif
|