From 9433201694d540f9ecaf7ea42872a1915d1b0a2c Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Tue, 8 Apr 2014 11:56:29 +0000 Subject: [PATCH] Pass JT9W tone spacing to Modulator via a signal/slot as it is crossing a thread boundary. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3995 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Modulator.cpp | 5 ++++- Modulator.hpp | 4 ++-- mainwindow.cpp | 6 +++--- mainwindow.h | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Modulator.cpp b/Modulator.cpp index a4358bbd4..af7d31aa8 100644 --- a/Modulator.cpp +++ b/Modulator.cpp @@ -29,6 +29,8 @@ Modulator::Modulator (unsigned frameRate, unsigned periodLengthInSeconds, QObjec , m_stream {nullptr} , m_quickClose {false} , m_phi {0.0} + , m_toneSpacing {0.0} + , m_fSpread {0.0} , m_frameRate {frameRate} , m_period {periodLengthInSeconds} , m_state {Idle} @@ -40,7 +42,7 @@ Modulator::Modulator (unsigned frameRate, unsigned periodLengthInSeconds, QObjec // seed } -void Modulator::start (unsigned symbolsLength, double framesPerSymbol, unsigned frequency, SoundOutput * stream, Channel channel, bool synchronize, double dBSNR) +void Modulator::start (unsigned symbolsLength, double framesPerSymbol, unsigned frequency, double toneSpacing, SoundOutput * stream, Channel channel, bool synchronize, double dBSNR) { Q_ASSERT (stream); @@ -62,6 +64,7 @@ void Modulator::start (unsigned symbolsLength, double framesPerSymbol, unsigned m_nsps = framesPerSymbol; m_frequency = frequency; m_amp = std::numeric_limits::max (); + m_toneSpacing = toneSpacing; // noise generator parameters if (m_addNoise) { diff --git a/Modulator.hpp b/Modulator.hpp index 88ece3f4b..365d7da09 100644 --- a/Modulator.hpp +++ b/Modulator.hpp @@ -30,9 +30,9 @@ public: bool isMuted () const {return m_muted;} unsigned frequency () const {return m_frequency;} bool isActive () const {return m_state != Idle;} - void setWide9(double d1, double d2) {m_toneSpacing=d1; m_fSpread=d2;} + void setSpread(double s) {m_fSpread=s;} - Q_SLOT void start (unsigned symbolsLength, double framesPerSymbol, unsigned frequency, SoundOutput *, Channel = Mono, bool synchronize = true, double dBSNR = 99.); + Q_SLOT void start (unsigned symbolsLength, double framesPerSymbol, unsigned frequency, double toneSpacing, SoundOutput *, Channel = Mono, bool synchronize = true, double dBSNR = 99.); Q_SLOT void stop (bool quick = false); Q_SLOT void tune (bool newState = true); Q_SLOT void mute (bool newState = true) {m_muted = newState;} diff --git a/mainwindow.cpp b/mainwindow.cpp index 7d33f7bf3..47d1fb3e0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1667,7 +1667,7 @@ void MainWindow::startTx2() double snr=99.0; QString t=ui->tx5->currentText(); if(t.mid(0,1)=="#") fSpread=t.mid(1,5).toDouble(); - m_modulator.setWide9(m_toneSpacing, fSpread); + m_modulator.setSpread(fSpread); t=ui->tx6->text(); if(t.mid(0,1)=="#") snr=t.mid(1,5).toDouble(); if(snr>0.0 or snr < -50.0) snr=99.0; @@ -2841,11 +2841,11 @@ void MainWindow::transmit (double snr) { if (m_modeTx == "JT65") { - Q_EMIT sendMessage (NUM_JT65_SYMBOLS, 4096.0 * 12000.0 / 11025.0, m_txFreq - m_XIT, &m_soundOutput, m_config.audio_output_channel (), true, snr); + Q_EMIT sendMessage (NUM_JT65_SYMBOLS, 4096.0 * 12000.0 / 11025.0, m_txFreq - m_XIT, m_toneSpacing, &m_soundOutput, m_config.audio_output_channel (), true, snr); } else { - Q_EMIT sendMessage (NUM_JT9_SYMBOLS, m_nsps, m_txFreq - m_XIT, &m_soundOutput, m_config.audio_output_channel (), true, snr); + Q_EMIT sendMessage (NUM_JT9_SYMBOLS, m_nsps, m_txFreq - m_XIT, m_toneSpacing, &m_soundOutput, m_config.audio_output_channel (), true, snr); } } diff --git a/mainwindow.h b/mainwindow.h index 7ed28f79f..b5b3014ff 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -192,7 +192,7 @@ private: Q_SIGNAL void transmitFrequency (unsigned) const; Q_SIGNAL void endTransmitMessage (bool quick = false) const; Q_SIGNAL void tune (bool = true) const; - Q_SIGNAL void sendMessage (unsigned symbolsLength, double framesPerSymbol, unsigned frequency, SoundOutput *, AudioDevice::Channel = AudioDevice::Mono, bool synchronize = true, double dBSNR = 99.) const; + Q_SIGNAL void sendMessage (unsigned symbolsLength, double framesPerSymbol, unsigned frequency, double toneSpacing, SoundOutput *, AudioDevice::Channel = AudioDevice::Mono, bool synchronize = true, double dBSNR = 99.) const; Q_SIGNAL void outAttenuationChanged (qreal) const; private: