Merged master 8748
This commit is contained in:
@@ -1,94 +0,0 @@
|
||||
#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;}
|
||||
void set_nsym(int n) {m_symbolsLength=n;}
|
||||
|
||||
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;
|
||||
unsigned 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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,46 +0,0 @@
|
||||
// -*- Mode: C++ -*-
|
||||
#ifndef DISPLAYTEXT_H
|
||||
#define DISPLAYTEXT_H
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QFont>
|
||||
|
||||
#include "logbook/logbook.h"
|
||||
#include "decodedtext.h"
|
||||
|
||||
class QAction;
|
||||
|
||||
class DisplayText
|
||||
: public QTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DisplayText(QWidget *parent = 0);
|
||||
|
||||
void setContentFont (QFont const&);
|
||||
void insertLineSpacer(QString const&);
|
||||
void displayDecodedText(DecodedText const& decodedText, QString const& myCall, bool displayDXCCEntity,
|
||||
LogBook const& logBook, QColor color_CQ, QColor color_MyCall,
|
||||
QColor color_DXCC, QColor color_NewCall);
|
||||
void displayTransmittedText(QString text, QString modeTx, qint32 txFreq,
|
||||
QColor color_TxMsg, bool bFastMode);
|
||||
void displayQSY(QString text);
|
||||
|
||||
Q_SIGNAL void selectCallsign (Qt::KeyboardModifiers);
|
||||
Q_SIGNAL void erased ();
|
||||
|
||||
Q_SLOT void appendText (QString const& text, QColor bg = Qt::white);
|
||||
Q_SLOT void erase ();
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
QString appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, LogBook const& logBook,
|
||||
QColor color_CQ, QColor color_DXCC, QColor color_NewCall);
|
||||
|
||||
QFont char_font_;
|
||||
QAction * erase_action_;
|
||||
};
|
||||
|
||||
#endif // DISPLAYTEXT_H
|
||||
@@ -0,0 +1,136 @@
|
||||
#include "NetworkMessage.hpp"
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
|
||||
#include "pimpl_impl.hpp"
|
||||
|
||||
namespace NetworkMessage
|
||||
{
|
||||
Builder::Builder (QIODevice * device, Type type, QString const& id, quint32 schema)
|
||||
: QDataStream {device}
|
||||
{
|
||||
common_initialization (type, id, schema);
|
||||
}
|
||||
|
||||
Builder::Builder (QByteArray * a, Type type, QString const& id, quint32 schema)
|
||||
: QDataStream {a, QIODevice::WriteOnly}
|
||||
{
|
||||
common_initialization (type, id, schema);
|
||||
}
|
||||
|
||||
void Builder::common_initialization (Type type, QString const& id, quint32 schema)
|
||||
{
|
||||
if (schema <= 1)
|
||||
{
|
||||
setVersion (QDataStream::Qt_5_0); // Qt schema version
|
||||
}
|
||||
#if QT_VERSION >= 0x050200
|
||||
else if (schema <= 2)
|
||||
{
|
||||
setVersion (QDataStream::Qt_5_2); // Qt schema version
|
||||
}
|
||||
#endif
|
||||
#if QT_VERSION >= 0x050400
|
||||
else if (schema <= 3)
|
||||
{
|
||||
setVersion (QDataStream::Qt_5_4); // Qt schema version
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
throw std::runtime_error {"Unrecognized message schema"};
|
||||
}
|
||||
|
||||
// the following two items assume that the quint32 encoding is
|
||||
// unchanged over QDataStream versions
|
||||
*this << magic;
|
||||
*this << schema;
|
||||
|
||||
*this << static_cast<quint32> (type) << id.toUtf8 ();
|
||||
}
|
||||
|
||||
class Reader::impl
|
||||
{
|
||||
public:
|
||||
void common_initialization (Reader * parent)
|
||||
{
|
||||
quint32 magic;
|
||||
*parent >> magic;
|
||||
if (magic != Builder::magic)
|
||||
{
|
||||
throw std::runtime_error {"Invalid message format"};
|
||||
}
|
||||
*parent >> schema_;
|
||||
if (schema_ > Builder::schema_number)
|
||||
{
|
||||
throw std::runtime_error {"Unrecognized message schema"};
|
||||
}
|
||||
if (schema_ <= 1)
|
||||
{
|
||||
parent->setVersion (QDataStream::Qt_5_0);
|
||||
}
|
||||
#if QT_VERSION >= 0x050200
|
||||
else if (schema_ <= 2)
|
||||
{
|
||||
parent->setVersion (QDataStream::Qt_5_2);
|
||||
}
|
||||
#endif
|
||||
#if QT_VERSION >= 0x050400
|
||||
else if (schema_ <= 3)
|
||||
{
|
||||
parent->setVersion (QDataStream::Qt_5_4);
|
||||
}
|
||||
#endif
|
||||
quint32 type;
|
||||
*parent >> type >> id_;
|
||||
if (type >= maximum_message_type_)
|
||||
{
|
||||
qDebug () << "Unrecognized message type:" << type << "from id:" << id_;
|
||||
type_ = maximum_message_type_;
|
||||
}
|
||||
else
|
||||
{
|
||||
type_ = static_cast<Type> (type);
|
||||
}
|
||||
}
|
||||
|
||||
quint32 schema_;
|
||||
Type type_;
|
||||
QByteArray id_;
|
||||
};
|
||||
|
||||
Reader::Reader (QIODevice * device)
|
||||
: QDataStream {device}
|
||||
{
|
||||
m_->common_initialization (this);
|
||||
}
|
||||
|
||||
Reader::Reader (QByteArray const& a)
|
||||
: QDataStream {a}
|
||||
{
|
||||
m_->common_initialization (this);
|
||||
}
|
||||
|
||||
Reader::~Reader ()
|
||||
{
|
||||
}
|
||||
|
||||
quint32 Reader::schema () const
|
||||
{
|
||||
return m_->schema_;
|
||||
}
|
||||
|
||||
Type Reader::type () const
|
||||
{
|
||||
return static_cast<Type> (m_->type_);
|
||||
}
|
||||
|
||||
QString Reader::id () const
|
||||
{
|
||||
return QString::fromUtf8 (m_->id_);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user