mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-29 19:28:47 -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:
parent
1f60fa48d0
commit
85c8129d9c
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user