Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
tdl.hpp
1
12
13#ifndef QLIBS_TDL
14#define QLIBS_TDL
15
16#include <include/qlibs_types.hpp>
17
21namespace qlibs {
26
27
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
41 void insertNewest( const real_t sample ) noexcept;
42 void removeOldest( void ) noexcept;
44 public:
45 virtual ~tdl() {}
46 tdl() = default;
47
54 tdl( real_t * const area,
55 const size_t n,
56 const real_t initVal = 0.0_re )
57 {
58 setup( area, n, initVal );
59 }
60
66 template <size_t numberOfDelays>
67 tdl( real_t (&area)[ numberOfDelays ],
68 const real_t initVal = 0.0_re ) noexcept
69 {
70 setup( area, numberOfDelays, initVal );
71 }
72
80 void setup( real_t * const area,
81 const size_t n,
82 const real_t initVal = 0.0_re ) noexcept;
83
90 template <size_t numberOfDelays>
91 void setup( real_t (&area)[ numberOfDelays ],
92 const real_t initVal = 0.0_re ) noexcept
93 {
94 setup( area, numberOfDelays, initVal );
95 }
96
101 void flush( const real_t initVal = 0.0_re ) noexcept;
102
107 real_t getOldest( void ) const noexcept;
108
113 real_t getRecent( void ) const noexcept;
114
120 real_t getAtIndex( const size_t i ) const noexcept;
121
126 void insertSample( const real_t sample ) noexcept;
127
133 real_t operator[]( int index ) noexcept;
134
139 void operator()( const real_t sample ) noexcept
140 {
141 insertSample( sample );
142 }
143
148 bool isInitialized( void ) const {
149 return ( nullptr != head );
150 }
151 };
152
154}
155
156
157#endif /*QLIBS_TDL*/
bool isInitialized(void) const
Check if the TDL has been initialized.
Definition tdl.hpp:148
void operator()(const real_t sample) noexcept
Insert a new sample to the TDL removing the oldest sample.
Definition tdl.hpp:139
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:45
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:91
real_t operator[](int index) noexcept
Get the specified delayed sample from the TDL x(k-i)
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:54
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:67
real_t getOldest(void) const noexcept
Get the oldest sample from the TDL x(k-n)
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 mat.hpp:18
float real_t
A type to instantiate a real variable double-precision of 64-bits IEEE 754.
Definition qlibs_types.hpp:43