Add message stacking

qcpfix
Phil Taylor 2023-02-17 23:57:53 +00:00
rodzic acec37ea17
commit ed1e8c3a8e
2 zmienionych plików z 22 dodań i 9 usunięć

Wyświetl plik

@ -119,17 +119,26 @@ void cwSidetone::init()
void cwSidetone::send(QString text)
{
if (output != Q_NULLPTR && outputDevice != Q_NULLPTR) {
text=text.simplified();
buffer.clear();
QString currentChar;
messages.push_back(text.simplified());
if (messages.size() > 1) {
// There are already queued messages so just return
return;
}
QString currentChar;
if (output->state() == QAudio::StoppedState || output->state() == QAudio::SuspendedState) {
output->resume();
}
for (auto txt = messages.begin(); txt != messages.end();)
{
int pos = 0;
if (output->state() == QAudio::StoppedState || output->state() == QAudio::SuspendedState) {
output->resume();
}
while (pos < text.size())
buffer.clear();
while (pos < txt->size())
{
QChar ch = text.at(pos).toUpper();
QChar ch = txt->at(pos).toUpper();
if (ch == NULL)
{
currentChar = cwTable[' '];
@ -157,6 +166,7 @@ void cwSidetone::send(QString text)
qWarning(logCW()) << QString("Sidetone sending error occurred, aborting (%0 bytes of %1 remaining)").arg(buffer.size()-written).arg(buffer.size());
}
}
txt = messages.erase(txt);
}
//qInfo(logCW()) << "Sending" << this->currentChar;
emit finished();

Wyświetl plik

@ -18,6 +18,8 @@
#include <QtEndian>
#include <QTimer>
#include <deque>
//#define SIDETONE_MULTIPLIER 386.0
#define SIDETONE_MULTIPLIER 1095.46
@ -52,6 +54,7 @@ private:
int frequency;
double ratio;
QAudioFormat format;
std::deque <QString> messages;
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QAudioOutput* output = Q_NULLPTR;
#else