SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Private Attributes | List of all members
CWSmoother Class Reference

#include <cwkeyer.h>

Public Member Functions

 CWSmoother ()
 
 ~CWSmoother ()
 
void setNbFadeSamples (unsigned int nbFadeSamples)
 
bool getFadeSample (bool on, float &sample)
 

Private Attributes

QMutex m_mutex
 
unsigned int m_fadeInCounter
 
unsigned int m_fadeOutCounter
 
unsigned int m_nbFadeSamples
 
float * m_fadeInSamples
 
float * m_fadeOutSamples
 

Detailed Description

Ancillary class to smooth out CW transitions with a sine shape

Definition at line 34 of file cwkeyer.h.

Constructor & Destructor Documentation

◆ CWSmoother()

CWSmoother::CWSmoother ( )

Definition at line 443 of file cwkeyer.cpp.

References setNbFadeSamples().

443  :
444  m_fadeInCounter(0),
445  m_fadeOutCounter(0),
446  m_nbFadeSamples(0),
447  m_fadeInSamples(0),
449 {
450  setNbFadeSamples(192); // default is 4 ms at 48 kHz sample rate
451 }
void setNbFadeSamples(unsigned int nbFadeSamples)
Definition: cwkeyer.cpp:459
float * m_fadeOutSamples
Definition: cwkeyer.h:49
unsigned int m_nbFadeSamples
Definition: cwkeyer.h:47
unsigned int m_fadeInCounter
Definition: cwkeyer.h:45
unsigned int m_fadeOutCounter
Definition: cwkeyer.h:46
float * m_fadeInSamples
Definition: cwkeyer.h:48
+ Here is the call graph for this function:

◆ ~CWSmoother()

CWSmoother::~CWSmoother ( )

Definition at line 453 of file cwkeyer.cpp.

References m_fadeInSamples, and m_fadeOutSamples.

454 {
455  delete[] m_fadeInSamples;
456  delete[] m_fadeOutSamples;
457 }
float * m_fadeOutSamples
Definition: cwkeyer.h:49
float * m_fadeInSamples
Definition: cwkeyer.h:48

Member Function Documentation

◆ getFadeSample()

bool CWSmoother::getFadeSample ( bool  on,
float &  sample 
)

Definition at line 487 of file cwkeyer.cpp.

References m_fadeInCounter, m_fadeInSamples, m_fadeOutCounter, m_fadeOutSamples, m_mutex, and m_nbFadeSamples.

Referenced by WFMMod::pullAF(), AMMod::pullAF(), NFMMod::pullAF(), FreeDVMod::pullAF(), and SSBMod::pullAF().

488 {
489  QMutexLocker mutexLocker(&m_mutex);
490 
491  if (on)
492  {
493  m_fadeOutCounter = 0;
494 
496  {
498  m_fadeInCounter++;
499  return true;
500  }
501  else
502  {
503  sample = 1.0f;
504  return false;
505  }
506  }
507  else
508  {
509  m_fadeInCounter = 0;
510 
512  {
515  return true;
516  }
517  else
518  {
519  sample = 0.0f;
520  return false;
521  }
522  }
523 }
QMutex m_mutex
Definition: cwkeyer.h:44
float * m_fadeOutSamples
Definition: cwkeyer.h:49
unsigned int m_nbFadeSamples
Definition: cwkeyer.h:47
unsigned int m_fadeInCounter
Definition: cwkeyer.h:45
unsigned int m_fadeOutCounter
Definition: cwkeyer.h:46
float * m_fadeInSamples
Definition: cwkeyer.h:48
+ Here is the caller graph for this function:

◆ setNbFadeSamples()

void CWSmoother::setNbFadeSamples ( unsigned int  nbFadeSamples)

Definition at line 459 of file cwkeyer.cpp.

References i, m_fadeInCounter, m_fadeInSamples, m_fadeOutCounter, m_fadeOutSamples, m_mutex, m_nbFadeSamples, and StepFunctions::smootherstep().

Referenced by CWSmoother().

460 {
461  if (nbFadeSamples != m_nbFadeSamples)
462  {
463  QMutexLocker mutexLocker(&m_mutex);
464 
465  m_nbFadeSamples = nbFadeSamples;
466 
467  if (m_fadeInSamples) delete[] m_fadeInSamples;
468  if (m_fadeOutSamples) delete[] m_fadeOutSamples;
469 
470  m_fadeInSamples = new float[m_nbFadeSamples];
471  m_fadeOutSamples = new float[m_nbFadeSamples];
472 
473  for (unsigned int i = 0; i < m_nbFadeSamples; i++)
474  {
475  float x = i/ (float) m_nbFadeSamples;
476  float y = 1.0f -x;
477 
480  }
481 
482  m_fadeInCounter = 0;
483  m_fadeOutCounter = 0;
484  }
485 }
static float smootherstep(float x)
Definition: stepfunctions.h:24
QMutex m_mutex
Definition: cwkeyer.h:44
int32_t i
Definition: decimators.h:244
float * m_fadeOutSamples
Definition: cwkeyer.h:49
unsigned int m_nbFadeSamples
Definition: cwkeyer.h:47
unsigned int m_fadeInCounter
Definition: cwkeyer.h:45
unsigned int m_fadeOutCounter
Definition: cwkeyer.h:46
float * m_fadeInSamples
Definition: cwkeyer.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_fadeInCounter

unsigned int CWSmoother::m_fadeInCounter
private

Definition at line 45 of file cwkeyer.h.

Referenced by getFadeSample(), and setNbFadeSamples().

◆ m_fadeInSamples

float* CWSmoother::m_fadeInSamples
private

Definition at line 48 of file cwkeyer.h.

Referenced by getFadeSample(), setNbFadeSamples(), and ~CWSmoother().

◆ m_fadeOutCounter

unsigned int CWSmoother::m_fadeOutCounter
private

Definition at line 46 of file cwkeyer.h.

Referenced by getFadeSample(), and setNbFadeSamples().

◆ m_fadeOutSamples

float* CWSmoother::m_fadeOutSamples
private

Definition at line 49 of file cwkeyer.h.

Referenced by getFadeSample(), setNbFadeSamples(), and ~CWSmoother().

◆ m_mutex

QMutex CWSmoother::m_mutex
private

Definition at line 44 of file cwkeyer.h.

Referenced by CWKeyer::applySettings(), getFadeSample(), and setNbFadeSamples().

◆ m_nbFadeSamples

unsigned int CWSmoother::m_nbFadeSamples
private

Definition at line 47 of file cwkeyer.h.

Referenced by getFadeSample(), and setNbFadeSamples().


The documentation for this class was generated from the following files: