2023-02-17 13:58:02 +00:00
|
|
|
#ifndef CWSIDETONE_H
|
|
|
|
#define CWSIDETONE_H
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QAudioOutput>
|
|
|
|
#include <QMap>
|
|
|
|
|
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
|
|
|
|
#include <QAudioDeviceInfo>
|
|
|
|
#include <QAudioOutput>
|
|
|
|
#else
|
|
|
|
#include <QAudioDevice>
|
|
|
|
#include <QAudioSink>
|
|
|
|
#include <QMediaDevices>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <QtMath>
|
|
|
|
#include <QtEndian>
|
|
|
|
#include <QTimer>
|
|
|
|
|
2023-02-17 23:57:53 +00:00
|
|
|
#include <deque>
|
|
|
|
|
2023-02-17 23:21:29 +00:00
|
|
|
//#define SIDETONE_MULTIPLIER 386.0
|
|
|
|
#define SIDETONE_MULTIPLIER 1095.46
|
2023-02-17 13:58:02 +00:00
|
|
|
|
|
|
|
class cwSidetone : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit cwSidetone(int level, int speed, int freq, double ratio, QWidget *parent = 0);
|
|
|
|
~cwSidetone();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void finished();
|
|
|
|
public slots:
|
|
|
|
void send(QString text);
|
|
|
|
void setSpeed(unsigned char speed);
|
|
|
|
void setFrequency(unsigned char frequency);
|
|
|
|
void setRatio(unsigned char ratio);
|
|
|
|
void setLevel(int level);
|
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
|
|
|
|
void generateMorse(QString morse);
|
|
|
|
QByteArray generateData(qint64 len, qint64 freq);
|
|
|
|
QByteArray buffer;
|
|
|
|
QMap< QChar, QString> cwTable;
|
|
|
|
int position = 0;
|
|
|
|
int charSpace = 20;
|
|
|
|
int wordSpace = 60;
|
|
|
|
QWidget* parent;
|
|
|
|
int volume;
|
|
|
|
int speed;
|
|
|
|
int frequency;
|
|
|
|
double ratio;
|
|
|
|
QAudioFormat format;
|
2023-02-17 23:57:53 +00:00
|
|
|
std::deque <QString> messages;
|
2023-02-17 13:58:02 +00:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
|
|
|
|
QAudioOutput* output = Q_NULLPTR;
|
|
|
|
#else
|
|
|
|
QAudioSink* output = Q_NULLPTR;
|
|
|
|
#endif
|
|
|
|
QIODevice* outputDevice = Q_NULLPTR;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CWSIDETONE_H
|