1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

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

This commit is contained in:
f4exb 2017-10-21 05:00:23 +02:00
parent 1f60fa48d0
commit 85c8129d9c
2 changed files with 24 additions and 21 deletions

View File

@ -197,6 +197,7 @@ void CWKeyer::setWPM(int wpm)
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
m_dotLength = (int) (0.24f * m_sampleRate * (5.0f / wpm)); m_dotLength = (int) (0.24f * m_sampleRate * (5.0f / wpm));
m_wpm = wpm; m_wpm = wpm;
m_cwSmoother.setNbFadeSamples(m_dotLength/5); // 20% the dot time
} }
} }

View File

@ -23,6 +23,27 @@
#include "util/export.h" #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 { class SDRANGEL_API CWKeyer : public QObject {
Q_OBJECT Q_OBJECT
@ -68,6 +89,7 @@ public:
void setLoop(bool loop) { m_loop = loop; } void setLoop(bool loop) { m_loop = loop; }
void reset() { m_keyIambicState = KeySilent; } void reset() { m_keyIambicState = KeySilent; }
CWSmoother& getCWSmoother() { return m_cwSmoother; }
int getSample(); int getSample();
bool eom(); bool eom();
void resetText() { m_textState = TextStart; } void resetText() { m_textState = TextStart; }
@ -93,6 +115,7 @@ private:
CWMode m_mode; CWMode m_mode;
CWKeyIambicState m_keyIambicState; CWKeyIambicState m_keyIambicState;
CWTextState m_textState; CWTextState m_textState;
CWSmoother m_cwSmoother;
static const signed char m_asciiToMorse[128][7]; static const signed char m_asciiToMorse[128][7];
@ -100,25 +123,4 @@ private:
void nextStateText(); 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_ */ #endif /* SDRBASE_DSP_CWKEYER_H_ */