mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-09-08 22:36:40 -04:00
Currently only Qt5 or above is known to work with this code. It may be possible to backport it to Qt4 if required. Audio output goes back to a separate thread to try and minimize stutters in streaming on Windows particularly. A crash on Linux due to mishandling of stereo audio output has been fixed and both left and right channels are now correctly synthesised with identical contents. Rigs are enumerated directly from hamlib API rather than running a sub process reading output of rigctl -l. This was initially done to get rid of some GUI thread blocking in the configuration dialog, but is generally a better way of doing it anyway. Some refactoring in MainWindow to accomodate the audio streaming, modulation and detecting classes. Exit handling for application refactored to use signals rather than brute force event loop exit. This was required to get correct thread shutdown semantics. The GUI update timer is now stopped during application shutdown which is necessary to stop crashes when shutting down gracefully with signals and window close() calls. There is an outstanding issue with Linux audio streams; the QAudio Input/Output classes create a new stream name each time a stream is started. This doesn't play well with PulseAudio utilities such as pavucontrol to set stream volume as settings are lost every tx period. I have tried to keep a single stream for all output but there are problems restarting it that haven't been resolved yet. The QtCreator project file has been rearranged a little because it passes all the object files to the linker rather than using an archive library. Since the GNU linker is single pass; the object files need to be in a logical order with definitions appearing afer references to them. This was required to avoid a linking error. The lib/Makefile.linux has been enhanced to use the fortran compiler to locate the correct version of the Fortran library to use. This is necessary on the latest Linux distros because the unversioned symlink to compiler support libraries is no longer provided. This only an issue with mixed programming language links where the linker driver for one language has to link support libraraies for another language. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3532 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
94 lines
2.3 KiB
C++
94 lines
2.3 KiB
C++
#ifndef MODULATOR_HPP__
|
|
#define MODULATOR_HPP__
|
|
|
|
#include <QIODevice>
|
|
|
|
#ifdef UNIX
|
|
# define NUM_CHANNELS 2
|
|
#else
|
|
# define NUM_CHANNELS 1
|
|
#endif
|
|
|
|
//
|
|
// 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 QIODevice
|
|
{
|
|
Q_OBJECT;
|
|
|
|
Q_PROPERTY (unsigned frequency READ frequency WRITE setFrequency);
|
|
Q_PROPERTY (bool tuning READ isTuning WRITE tune);
|
|
Q_PROPERTY (bool muted READ isMuted WRITE mute);
|
|
|
|
private:
|
|
Q_DISABLE_COPY (Modulator);
|
|
|
|
public:
|
|
Modulator (unsigned frameRate, unsigned periodLengthInSeconds, QObject * parent = 0);
|
|
|
|
bool open () {return QIODevice::open (QIODevice::ReadOnly | QIODevice::Unbuffered);}
|
|
|
|
Q_SLOT void send (unsigned symbolsLength, double framesPerSymbol, unsigned frequency, bool synchronize = true, double dBSNR = 99.);
|
|
|
|
Q_SLOT void stop () {Q_EMIT stateChanged ((m_state = Idle));}
|
|
|
|
bool isTuning () const {return m_tuning;}
|
|
Q_SLOT void tune (bool newState = true) {m_tuning = newState;}
|
|
|
|
bool isMuted () const {return m_muted;}
|
|
Q_SLOT void mute (bool newState = true) {m_muted = newState;}
|
|
|
|
unsigned frequency () const {return m_frequency;}
|
|
Q_SLOT void setFrequency (unsigned newFrequency) {m_frequency = newFrequency;}
|
|
|
|
enum ModulatorState {Synchronizing, Active, Idle};
|
|
Q_SIGNAL void stateChanged (ModulatorState);
|
|
bool isActive () const {return m_state != Idle;}
|
|
|
|
bool isSequential () const {return true;}
|
|
|
|
protected:
|
|
qint64 readData (char * data, qint64 maxSize);
|
|
qint64 writeData (char const * /* data */, qint64 /* maxSize */)
|
|
{
|
|
return -1; // we don't consume data
|
|
}
|
|
|
|
private:
|
|
typedef struct
|
|
{
|
|
qint16 channel[NUM_CHANNELS];
|
|
} frame_t;
|
|
|
|
frame_t postProcessFrame (frame_t frame) const;
|
|
|
|
unsigned m_symbolsLength;
|
|
|
|
static double const m_twoPi;
|
|
static unsigned const m_nspd; // CW ID WPM factor
|
|
|
|
int m_frameRate;
|
|
int m_period;
|
|
double m_nsps;
|
|
double volatile m_frequency;
|
|
double m_snr;
|
|
qint64 m_silentFrames;
|
|
qint64 m_framesSent;
|
|
ModulatorState volatile m_state;
|
|
bool volatile m_tuning;
|
|
bool volatile m_muted;
|
|
bool m_addNoise;
|
|
double m_phi;
|
|
double m_dphi;
|
|
double m_amp;
|
|
unsigned m_ic;
|
|
double m_fac;
|
|
unsigned m_isym0;
|
|
};
|
|
|
|
#endif
|