Hopsan
|
Delay template class, implementing a circular buffer containing values of specified type. More...
#include <Delay.hpp>
Public Member Functions | |
void | initialize (const double timeDelay, const double Ts, const T initValue) |
Initialize delay buffer size based on timeDelay and timestep, Td/Ts must be multiple of 1 and >= 1. | |
void | initialize (const int delaySteps, const T initValue) |
Initialize delay size based on known number of delay steps. | |
T | update (const T newValue) |
Updates delay with a new value, "pop old", "push new". You should likely run this at the end of each time step. | |
T | getOldest () const |
Get the oldest value in the buffer. | |
T | getNewest () const |
Get the newest value in the buffer. | |
T | getIdx (const size_t i) const |
Returns a specific value, 0=newest, 1=nextnewest, 2=nextnextnewest and so on, no range check is performed. | |
T | getOldIdx (const size_t i) const |
Returns a specific value, 0=oldest, 1=nextoldest, 2=nextnextoldest and so on, no range check is performed. | |
size_t | getSize () const |
Get the size of the delay buffer (the number of buffer elements) | |
void | clear () |
Clear the delay buffer, deleting all data. | |
Delay template class, implementing a circular buffer containing values of specified type.
|
inline |
Returns a specific value, 0=newest, 1=nextnewest, 2=nextnextnewest and so on, no range check is performed.
[in] | i | Index of value to return |
|
inline |
Get the newest value in the buffer.
|
inline |
Get the oldest value in the buffer.
|
inline |
Returns a specific value, 0=oldest, 1=nextoldest, 2=nextnextoldest and so on, no range check is performed.
[in] | i | Index of value to return |
|
inline |
Get the size of the delay buffer (the number of buffer elements)
|
inline |
Initialize delay buffer size based on timeDelay and timestep, Td/Ts must be multiple of 1 and >= 1.
[in] | timeDelay | The total time delay for a value to come out on the other side of the circle buffer |
[in] | Ts | The timestep between each call |
[in] | initValue | The initial value of all buffer elements |
|
inline |
Initialize delay size based on known number of delay steps.
[in] | delaySteps | The number of delay steps, must be >= 1 |
[in] | initValue | The initial value of all buffer elements |
|
inline |
Updates delay with a new value, "pop old", "push new". You should likely run this at the end of each time step.
[in] | newValue | The new value to insert into delay buffer |