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
DoubleBufferFIFO< T > Class Template Reference

#include <doublebufferfifo.h>

Public Member Functions

 DoubleBufferFIFO (int size)
 
 ~DoubleBufferFIFO ()
 
void resize (int size)
 
void write (const T &element)
 
T & readBack (int delay)
 
void zeroBack (int delay)
 

Private Attributes

int m_size
 
T * m_data
 
int m_writeIndex
 
int m_currentIndex
 

Detailed Description

template<typename T>
class DoubleBufferFIFO< T >

Definition at line 23 of file doublebufferfifo.h.

Constructor & Destructor Documentation

◆ DoubleBufferFIFO()

template<typename T>
DoubleBufferFIFO< T >::DoubleBufferFIFO ( int  size)
inline

Definition at line 26 of file doublebufferfifo.h.

26  : m_size(size), m_writeIndex(0), m_currentIndex(0)
27  {
28  m_data = new T[2*m_size];
29  }

◆ ~DoubleBufferFIFO()

template<typename T>
DoubleBufferFIFO< T >::~DoubleBufferFIFO ( )
inline

Definition at line 31 of file doublebufferfifo.h.

32  {
33  delete[] m_data;
34  }

Member Function Documentation

◆ readBack()

template<typename T>
T& DoubleBufferFIFO< T >::readBack ( int  delay)
inline

Definition at line 58 of file doublebufferfifo.h.

Referenced by DSDDemod::feed(), AMDemod::processOneSample(), NFMDemod::processOneSample(), and SSBDemod::processOneSample().

59  {
60  if (delay > m_size) {
61  delay = m_size;
62  }
63 
64  return m_data[m_currentIndex + m_size - delay];
65  }
+ Here is the caller graph for this function:

◆ resize()

template<typename T>
void DoubleBufferFIFO< T >::resize ( int  size)
inline

Definition at line 36 of file doublebufferfifo.h.

Referenced by AMDemod::applyAudioSampleRate().

37  {
38  delete[] m_data;
39  m_size = size;
40  m_data = new T[2*m_size];
41  m_writeIndex = 0;
42  m_currentIndex = 0;
43  }
+ Here is the caller graph for this function:

◆ write()

template<typename T>
void DoubleBufferFIFO< T >::write ( const T &  element)
inline

Definition at line 45 of file doublebufferfifo.h.

Referenced by DSDDemod::feed(), AMDemod::processOneSample(), NFMDemod::processOneSample(), and SSBDemod::processOneSample().

46  {
47  m_data[m_writeIndex] = element;
48  m_data[m_writeIndex+m_size] = element;
50 
51  if (m_writeIndex < m_size - 1) {
52  m_writeIndex++;
53  } else {
54  m_writeIndex = 0;
55  }
56  }
+ Here is the caller graph for this function:

◆ zeroBack()

template<typename T>
void DoubleBufferFIFO< T >::zeroBack ( int  delay)
inline

Definition at line 67 of file doublebufferfifo.h.

Referenced by NFMDemod::processOneSample().

68  {
69  if (delay > m_size) {
70  delay = m_size;
71  }
72 
73  for (int i = 0; i < delay; i++) {
74  m_data[m_currentIndex + m_size - i] = 0;
75  }
76  }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_currentIndex

template<typename T>
int DoubleBufferFIFO< T >::m_currentIndex
private

◆ m_data

template<typename T>
T* DoubleBufferFIFO< T >::m_data
private

◆ m_size

template<typename T>
int DoubleBufferFIFO< T >::m_size
private

◆ m_writeIndex

template<typename T>
int DoubleBufferFIFO< T >::m_writeIndex
private

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