From 85c8129d9c18d3c57e29fcb8bc330cc5ca85d363 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 21 Oct 2017 05:00:23 +0200 Subject: [PATCH] CW keyer: have the smoother as a class member so it can be controlled by the keyer to determine the ramp length depending on dot length --- sdrbase/dsp/cwkeyer.cpp | 1 + sdrbase/dsp/cwkeyer.h | 44 +++++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/sdrbase/dsp/cwkeyer.cpp b/sdrbase/dsp/cwkeyer.cpp index 8357ab16d..6880d808b 100644 --- a/sdrbase/dsp/cwkeyer.cpp +++ b/sdrbase/dsp/cwkeyer.cpp @@ -197,6 +197,7 @@ void CWKeyer::setWPM(int wpm) QMutexLocker mutexLocker(&m_mutex); m_dotLength = (int) (0.24f * m_sampleRate * (5.0f / wpm)); m_wpm = wpm; + m_cwSmoother.setNbFadeSamples(m_dotLength/5); // 20% the dot time } } diff --git a/sdrbase/dsp/cwkeyer.h b/sdrbase/dsp/cwkeyer.h index d52a82ef9..0d8312c79 100644 --- a/sdrbase/dsp/cwkeyer.h +++ b/sdrbase/dsp/cwkeyer.h @@ -23,6 +23,27 @@ #include "util/export.h" +/** + * Ancillary class to smooth out CW transitions with a sine shape + */ +class CWSmoother +{ +public: + CWSmoother(); + ~CWSmoother(); + + void setNbFadeSamples(unsigned int nbFadeSamples); + bool getFadeSample(bool on, float& sample); + +private: + QMutex m_mutex; + unsigned int m_fadeInCounter; + unsigned int m_fadeOutCounter; + unsigned int m_nbFadeSamples; + float *m_fadeInSamples; + float *m_fadeOutSamples; +}; + class SDRANGEL_API CWKeyer : public QObject { Q_OBJECT @@ -68,6 +89,7 @@ public: void setLoop(bool loop) { m_loop = loop; } void reset() { m_keyIambicState = KeySilent; } + CWSmoother& getCWSmoother() { return m_cwSmoother; } int getSample(); bool eom(); void resetText() { m_textState = TextStart; } @@ -93,6 +115,7 @@ private: CWMode m_mode; CWKeyIambicState m_keyIambicState; CWTextState m_textState; + CWSmoother m_cwSmoother; static const signed char m_asciiToMorse[128][7]; @@ -100,25 +123,4 @@ private: void nextStateText(); }; -/** - * Ancillary class to smooth out CW transitions with a sine shape - */ -class CWSmoother -{ -public: - CWSmoother(); - ~CWSmoother(); - - void setNbFadeSamples(unsigned int nbFadeSamples); - bool getFadeSample(bool on, float& sample); - -private: - QMutex m_mutex; - unsigned int m_fadeInCounter; - unsigned int m_fadeOutCounter; - unsigned int m_nbFadeSamples; - float *m_fadeInSamples; - float *m_fadeOutSamples; -}; - #endif /* SDRBASE_DSP_CWKEYER_H_ */