From 753c52165e20e167293737c51c12782eedf64a8b Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Wed, 3 Jun 2015 19:55:21 +0000 Subject: [PATCH] Correct a flaw in soft-keying of CW ID. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5514 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Modulator.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Modulator.cpp b/Modulator.cpp index e4918d7ad..a62a31102 100644 --- a/Modulator.cpp +++ b/Modulator.cpp @@ -180,8 +180,16 @@ qint64 Modulator::readData (char * data, qint64 maxSize) m_phi += m_dphi; if (m_phi > m_twoPi) m_phi -= m_twoPi; - qint16 sample ((SOFT_KEYING ? qAbs (m_ramp - 1) : - (m_ramp ? 32767 : 0)) * qSin (m_phi)); + qint16 sample=0; + float amp=32767.0; + if(m_ramp!=0) { + float x=qSin(float(m_phi)); + if(SOFT_KEYING) { + amp=qAbs(qint32(m_ramp)); + if(amp>32767.0) amp=32767.0; + } + sample=round(amp*x); + } if (int (j) <= icw[0] && j < NUM_CW_SYMBOLS) // stop condition { @@ -198,16 +206,9 @@ qint64 Modulator::readData (char * data, qint64 maxSize) // adjust ramp if ((m_ramp != 0 && m_ramp != std::numeric_limits::min ()) || level != m_cwLevel) { - // either ramp has terminated at max/min or direction - // has changed + // either ramp has terminated at max/min or direction has changed m_ramp += RAMP_INCREMENT; // ramp } - - // if (m_cwLevel != level) - // { - // qDebug () << "@m_ic:" << m_ic << "icw[" << j << "] =" << icw[j] << "@" << framesGenerated << "in numFrames:" << numFrames; - // } - m_cwLevel = level; }