Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
tdl.hpp
1
13#ifndef QLIBS_TDL
14#define QLIBS_TDL
15
16#include <include/qlibs_types.hpp>
17
21namespace qlibs {
32 class tdl : private nonCopyable {
33 protected:
35 real_t *head{ nullptr };
36 real_t *tail{ nullptr };
37 real_t *rd{ nullptr };
38 real_t *wr{ nullptr };
39 size_t itemCount{ 0U };
40 const real_t undefined{ 0.0_re/0.0_re }; // skipcq: CXX-W2010
41
42 void insertNewest( const real_t sample ) noexcept;
43 void removeOldest( void ) noexcept;
45 public:
46 virtual ~tdl() {}
47 tdl() = default;
48
55 tdl( real_t * const area,
56 const size_t n,
57 const real_t initVal = 0.0_re )
58 {
59 setup( area, n, initVal );
60 }
61
67 template <size_t numberOfDelays>
68 tdl( real_t (&area)[ numberOfDelays ],
69 const real_t initVal = 0.0_re ) noexcept
70 {
71 setup( area, numberOfDelays, initVal );
72 }
73
82 void setup( real_t * const area,
83 const size_t n,
84 const real_t initVal = 0.0_re ) noexcept;
85
93 template <size_t numberOfDelays>
94 void setup( real_t (&area)[ numberOfDelays ],
95 const real_t initVal = 0.0_re ) noexcept
96 {
97 setup( area, numberOfDelays, initVal );
98 }
99
105 void flush( const real_t initVal = 0.0_re ) noexcept;
106
111 real_t getOldest( void ) const noexcept;
112
117 real_t getRecent( void ) const noexcept;
118
124 real_t getAtIndex( const size_t i ) const noexcept;
125
131 void insertSample( const real_t sample ) noexcept;
132
138 const real_t& operator[]( int index ) noexcept;
139
145 void operator()( const real_t sample ) noexcept
146 {
147 insertSample( sample );
148 }
149
154 bool isInitialized( void ) const {
155 return ( nullptr != head );
156 }
157 };
158
160}
161
162
163#endif /*QLIBS_TDL*/
A Tapped Delay Line (TDL) object.
Definition tdl.hpp:32
bool isInitialized(void) const
Check if the TDL has been initialized.
Definition tdl.hpp:154
void operator()(const real_t sample) noexcept
Insert a new sample to the TDL removing the oldest sample.
Definition tdl.hpp:145
void setup(real_t *const area, const size_t n, const real_t initVal=0.0_re) noexcept
Setup and initialize a Tapped Delay Line (TDL) instance by setting the default optimal parameters.
real_t getRecent(void) const noexcept
Get the most recent sample from the TDL x(k)
real_t getAtIndex(const size_t i) const noexcept
Get the specified delayed sample from the TDL x(k-i)
virtual ~tdl()
Definition tdl.hpp:46
void setup(real_t(&area)[numberOfDelays], const real_t initVal=0.0_re) noexcept
Setup and initialize a Tapped Delay Line (TDL) instance by setting the default optimal parameters.
Definition tdl.hpp:94
tdl(real_t *const area, const size_t n, const real_t initVal=0.0_re)
Constructor for the Tapped Delay Line (TDL) instance.
Definition tdl.hpp:55
tdl()=default
tdl(real_t(&area)[numberOfDelays], const real_t initVal=0.0_re) noexcept
Constructor for the Tapped Delay Line (TDL) instance.
Definition tdl.hpp:68
real_t getOldest(void) const noexcept
Get the oldest sample from the TDL x(k-n)
const real_t & operator[](int index) noexcept
Get the specified delayed sample from the TDL x(k-i)
void flush(const real_t initVal=0.0_re) noexcept
Clears all delays from the TDL and sets them to the specified value.
void insertSample(const real_t sample) noexcept
Insert a new sample to the TDL removing the oldest sample.
The qLibs++ library namespace.
Definition fp16.cpp:4
float real_t
A type to instantiate a real variable double-precision of 64-bits IEEE 754.
Definition qlibs_types.hpp:43