From 375e98f6524bfa71c02aa2139750b9b4972f89c2 Mon Sep 17 00:00:00 2001 From: David Freese Date: Thu, 5 Feb 2015 11:23:44 -0600 Subject: [PATCH] CW QSK Tune * Added right channel "tune" signal for QSK / keyer control via right channel tone. --- src/trx/tune.cxx | 57 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/src/trx/tune.cxx b/src/trx/tune.cxx index 055ca71e..0dbca6ce 100644 --- a/src/trx/tune.cxx +++ b/src/trx/tune.cxx @@ -72,7 +72,9 @@ double kushape[KNUM] = { #define BUFLEN 512 double phaseacc = 0.0; double phaseincr = 0.0; +double pttacc = 0.0; double outbuf[BUFLEN]; +double pttbuf[BUFLEN]; //=========================================================================== @@ -83,6 +85,14 @@ inline double nco() return cos(phaseacc); } +inline double pttnco() +{ + pttacc += TWOPI * 1000 / active_modem->get_samplerate(); + if (pttacc > TWOPI) pttacc -= TWOPI; + return sin(pttacc); +} + + //===================================================================== @@ -92,11 +102,21 @@ void keydown(double freq, SoundBase *scard) { int i; phaseincr = 2.0 * M_PI * freq / active_modem->get_samplerate(); - for (i = 0; i < KNUM; i++) + for (i = 0; i < KNUM; i++){ outbuf[i] = nco() * kdshape[i]; - for (; i < BUFLEN; i++) + pttbuf[i] = pttnco(); + } + for (; i < BUFLEN; i++) { outbuf[i] = nco(); - active_modem->ModulateXmtr(outbuf, BUFLEN); + pttbuf[i] = pttnco(); + } + if ((active_modem == cw_modem) && progdefaults.QSK) { + active_modem->ModulateStereo( + outbuf, pttbuf, + BUFLEN, false); + } else { + active_modem->ModulateXmtr(outbuf, BUFLEN); + } } //===================================================================== @@ -105,11 +125,21 @@ void keyup(double freq, SoundBase *scard) { int i; phaseincr = 2.0 * M_PI * freq / active_modem->get_samplerate(); - for (i = 0; i < KNUM; i++) + for (i = 0; i < KNUM; i++) { outbuf[i] = nco() * kushape[i]; - for (; i < BUFLEN; i++) + pttbuf[i] = pttnco(); + } + for (; i < BUFLEN; i++) { outbuf[i] = 0.0; - active_modem->ModulateXmtr(outbuf, BUFLEN); + pttbuf[i] = pttnco(); + } + if ((active_modem == cw_modem) && progdefaults.QSK) { + active_modem->ModulateStereo( + outbuf, pttbuf, + BUFLEN, false); + } else { + active_modem->ModulateXmtr(outbuf, BUFLEN); + } } //===================================================================== @@ -118,9 +148,18 @@ void tune(double freq, SoundBase *scard) { int i; phaseincr = 2.0 * M_PI * freq / active_modem->get_samplerate(); - for (i = 0; i < BUFLEN; i++) + + for (i = 0; i < BUFLEN; i++) { outbuf[i] = nco(); - active_modem->ModulateXmtr(outbuf, BUFLEN); + pttbuf[i] = pttnco(); + } + if ((active_modem == cw_modem) && progdefaults.QSK) { + active_modem->ModulateStereo( + outbuf, pttbuf, + BUFLEN, false); + } else { + active_modem->ModulateXmtr(outbuf, BUFLEN); + } } -} // namespace tune +}; // namespace tune