diff --git a/Detector.cpp b/Detector.cpp index 045d6380c..5b7a45aba 100644 --- a/Detector.cpp +++ b/Detector.cpp @@ -1,16 +1,16 @@ #include "Detector.hpp" - #include #include #include - #include "commons.h" extern "C" { void fil4_(qint16*, qint32*, qint16*, qint32*); } -Detector::Detector (unsigned frameRate, unsigned periodLengthInSeconds, unsigned framesPerSignal, unsigned downSampleFactor, QObject * parent) +Detector::Detector (unsigned frameRate, unsigned periodLengthInSeconds, + unsigned framesPerSignal, unsigned downSampleFactor, + QObject * parent) : AudioDevice (parent) , m_frameRate (frameRate) , m_period (periodLengthInSeconds) @@ -18,7 +18,8 @@ Detector::Detector (unsigned frameRate, unsigned periodLengthInSeconds, unsigned , m_framesPerSignal (framesPerSignal) , m_monitoring (false) , m_starting (false) - , m_buffer ((downSampleFactor > 1) ? new short [framesPerSignal * downSampleFactor] : 0) + , m_buffer ((downSampleFactor > 1) ? + new short [framesPerSignal * downSampleFactor] : 0) , m_bufferPos (0) { clear (); @@ -44,79 +45,78 @@ void Detector::clear () qint64 Detector::writeData (char const * data, qint64 maxSize) { - if (m_monitoring) - { - Q_ASSERT (!(maxSize % static_cast (bytesPerFrame ()))); // no torn frames + if (m_monitoring) { + // no torn frames + Q_ASSERT (!(maxSize % static_cast (bytesPerFrame ()))); + // these are in terms of input frames (not down sampled) + size_t framesAcceptable ((sizeof (jt9com_.d2) / + sizeof (jt9com_.d2[0]) - jt9com_.kin) * m_downSampleFactor); + size_t framesAccepted (qMin (static_cast (maxSize / + bytesPerFrame ()), framesAcceptable)); - // these are in terms of input frames (not down sampled) - size_t framesAcceptable ((sizeof (jt9com_.d2) / sizeof (jt9com_.d2[0]) - jt9com_.kin) * m_downSampleFactor); - size_t framesAccepted (qMin (static_cast (maxSize / bytesPerFrame ()), framesAcceptable)); + if (framesAccepted < static_cast (maxSize / bytesPerFrame ())) { + qDebug () << "dropped " << maxSize / bytesPerFrame () - framesAccepted + << " frames of data on the floor!"; + } - if (framesAccepted < static_cast (maxSize / bytesPerFrame ())) - { - qDebug () << "dropped " << maxSize / bytesPerFrame () - framesAccepted << " frames of data on the floor!"; - } + for (unsigned remaining = framesAccepted; remaining; ) { + size_t numFramesProcessed (qMin (m_framesPerSignal * + m_downSampleFactor - m_bufferPos, remaining)); - for (unsigned remaining = framesAccepted; remaining; ) - { - size_t numFramesProcessed (qMin (m_framesPerSignal * m_downSampleFactor - m_bufferPos, remaining)); + if(m_downSampleFactor > 1) { + store (&data[(framesAccepted - remaining) * bytesPerFrame ()], + numFramesProcessed, &m_buffer[m_bufferPos]); + m_bufferPos += numFramesProcessed; + if(m_bufferPos==m_framesPerSignal*m_downSampleFactor && m_monitoring) { + qint32 framesToProcess (m_framesPerSignal * m_downSampleFactor); + qint32 framesAfterDownSample; + if(framesToProcess!=13824) qDebug() << "framesToProcess =" + << framesToProcess; + if(jt9com_.kin<0 or jt9com_.kin>=1440000) qDebug() << "jt9com_.kin =" + << jt9com_.kin; + fil4_(&m_buffer[0], &framesToProcess, &jt9com_.d2[jt9com_.kin], + &framesAfterDownSample); + Q_ASSERT(framesAfterDownSample==3456); + jt9com_.kin += framesAfterDownSample; + Q_EMIT framesWritten (jt9com_.kin); + m_bufferPos = 0; + } - if (m_downSampleFactor > 1) - { - store (&data[(framesAccepted - remaining) * bytesPerFrame ()], numFramesProcessed, &m_buffer[m_bufferPos]); - m_bufferPos += numFramesProcessed; - if (m_bufferPos == m_framesPerSignal * m_downSampleFactor && m_monitoring) - { - qint32 framesToProcess (m_framesPerSignal * m_downSampleFactor); - qint32 framesAfterDownSample; - fil4_(&m_buffer[0], &framesToProcess, &jt9com_.d2[jt9com_.kin], &framesAfterDownSample); - jt9com_.kin += framesAfterDownSample; - Q_EMIT framesWritten (jt9com_.kin); - m_bufferPos = 0; - } - - } - else - { - store (&data[(framesAccepted - remaining) * bytesPerFrame ()], numFramesProcessed, &jt9com_.d2[jt9com_.kin]); - m_bufferPos += numFramesProcessed; - jt9com_.kin += numFramesProcessed; - if (m_bufferPos == static_cast (m_framesPerSignal) && m_monitoring) - { - Q_EMIT framesWritten (jt9com_.kin); - m_bufferPos = 0; - } - } - - if (!secondInPeriod ()) - { - if (!m_starting) - { - // next samples will be in new period so wrap around to - // start of buffer - // - // we don't bother calling reset () since we expect to fill - // the whole buffer and don't need to waste cycles zeroing - jt9com_.kin = 0; - m_bufferPos = 0; - m_starting = true; - } - } - else if (m_starting) - { - m_starting = false; - } - remaining -= numFramesProcessed; - } - } - else - { - jt9com_.kin = 0; - m_bufferPos = 0; + } else { + store (&data[(framesAccepted - remaining) * bytesPerFrame ()], + numFramesProcessed, &jt9com_.d2[jt9com_.kin]); + m_bufferPos += numFramesProcessed; + jt9com_.kin += numFramesProcessed; + if (m_bufferPos == static_cast (m_framesPerSignal) && + m_monitoring) { + Q_EMIT framesWritten (jt9com_.kin); + m_bufferPos = 0; + } } - return maxSize; // we drop any data past the end of the buffer on - // the floor until the next period starts + if (!secondInPeriod ()) { + if (!m_starting) { + // next samples will be in new period so wrap around to + // start of buffer + // + // we don't bother calling reset () since we expect to fill + // the whole buffer and don't need to waste cycles zeroing + jt9com_.kin = 0; + m_bufferPos = 0; + m_starting = true; + } + } else if(m_starting) { + m_starting = false; + } + remaining -= numFramesProcessed; + } +} else { +jt9com_.kin = 0; +m_bufferPos = 0; +} + +return maxSize; // we drop any data past the end of the buffer on + // the floor until the next period starts } unsigned Detector::secondInPeriod () const diff --git a/Modulator.cpp b/Modulator.cpp index 6b0fa5072..d4ca21ce3 100644 --- a/Modulator.cpp +++ b/Modulator.cpp @@ -85,6 +85,7 @@ void Modulator::open (unsigned symbolsLength, double framesPerSymbol, unsigned f qint64 Modulator::readData (char * data, qint64 maxSize) { + if(maxSize==0) return 0; Q_ASSERT (!(maxSize % static_cast (bytesPerFrame ()))); // no torn frames Q_ASSERT (isOpen ()); diff --git a/mainwindow.cpp b/mainwindow.cpp index 4850286be..f77c2e850 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -36,7 +36,7 @@ QTextEdit* pShortcuts; QTcpSocket* commanderSocket = new QTcpSocket(0); QString rev="$Rev$"; -QString Program_Title_Version=" WSJT-X v1.2.1, r" + rev.mid(6,4) + +QString Program_Title_Version=" WSJT-X v1.2.2, r" + rev.mid(6,4) + " by K1JT"; //-------------------------------------------------- MainWindow constructor @@ -49,7 +49,7 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the ui(new Ui::MainWindow), m_wideGraph (new WideGraph (settings)), m_logDlg (new LogQSO (settings, this)), - m_detector (RX_SAMPLE_RATE, NTMAX / 2, 6912 / 2, downSampleFactor), + m_detector (RX_SAMPLE_RATE, NTMAX/2, 6912/2, downSampleFactor), m_audioInputDevice (QAudioDeviceInfo::defaultInputDevice ()), // start with default m_modulator (TX_SAMPLE_RATE, NTMAX / 2), m_audioOutputDevice (QAudioDeviceInfo::defaultOutputDevice ()), // start with default @@ -711,6 +711,7 @@ void MainWindow::dataSink(qint64 frames) jt9com_.ndiskdat=0; } + // Get power, spectrum, and ihsym trmin=m_TRperiod/60; slope=0.0; diff --git a/psk_reporter.cpp b/psk_reporter.cpp index 1e2164547..7fbcaf668 100644 --- a/psk_reporter.cpp +++ b/psk_reporter.cpp @@ -113,7 +113,7 @@ void PSK_Reporter::dnsLookupResult(QHostInfo info) { if (!info.addresses().isEmpty()) { m_pskReporterAddress = info.addresses().at(0); - qDebug() << "PSK Reporter IP: " << m_pskReporterAddress; +// qDebug() << "PSK Reporter IP: " << m_pskReporterAddress; } } diff --git a/soundout.cpp b/soundout.cpp index a1d726907..cf0309a4f 100644 --- a/soundout.cpp +++ b/soundout.cpp @@ -78,6 +78,7 @@ void SoundOutput::startStream (QAudioDeviceInfo const& device, unsigned channels m_stream.reset (new QAudioOutput (device, format, this)); audioError (); m_stream->setVolume (m_volume); + m_stream->setNotifyInterval(100); connect (m_stream.data(), &QAudioOutput::stateChanged, this, &SoundOutput::handleStateChanged); @@ -129,7 +130,7 @@ void SoundOutput::setAttenuation (qreal a) { Q_ASSERT (0. <= a && a <= 99.); m_volume = qPow (10., -a / 10.); - qDebug () << "SoundOut: attn = " << a << ", vol = " << m_volume; +// qDebug () << "SoundOut: attn = " << a << ", vol = " << m_volume; if (m_stream) { m_stream->setVolume (m_volume); diff --git a/wsjtx.iss b/wsjtx.iss index c08dcf210..f3d9fb25c 100644 --- a/wsjtx.iss +++ b/wsjtx.iss @@ -1,6 +1,6 @@ [Setup] AppName=wsjtx -AppVerName=wsjtx Version 1.2.1 r3587 +AppVerName=wsjtx Version 1.2.1a r3590 AppCopyright=Copyright (C) 2001-2013 by Joe Taylor, K1JT DefaultDirName=c:\wsjtx1.2 DefaultGroupName=wsjtx1.2 diff --git a/wsjtx.pro b/wsjtx.pro index 418c2e5d7..69ff9ece2 100644 --- a/wsjtx.pro +++ b/wsjtx.pro @@ -7,7 +7,7 @@ QT += network multimedia greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += thread -#CONFIG += console +CONFIG += console TARGET = wsjtx #DESTDIR = ../qt4_install