Functions
tRingBuffer

Ring buffer. More...

Functions

void tRingBuffer_init (tRingBuffer *const ring, int size, LEAF *const leaf)
 Initialize a tRingBuffer to the default mempool of a LEAF instance. More...
 
void tRingBuffer_initToPool (tRingBuffer *const ring, int size, tMempool *const mempool)
 Initialize a tRingBuffer to a specified mempool. More...
 
void tRingBuffer_free (tRingBuffer *const ring)
 Free a tRingBuffer from its mempool. More...
 
void tRingBuffer_push (tRingBuffer *const ring, float val)
 Push a value to the ring buffer, overwriting the oldest value if the buffer is full. More...
 
float tRingBuffer_getNewest (tRingBuffer *const ring)
 Get the newest value in the ring buffer. More...
 
float tRingBuffer_getOldest (tRingBuffer *const ring)
 Get the oldest value in the ring buffer. More...
 
float tRingBuffer_get (tRingBuffer *const ring, int index)
 Get the value at an index of the buffer. More...
 
int tRingBuffer_getSize (tRingBuffer *const ring)
 Get the size of the ring buffer. More...
 

Detailed Description

Ring buffer.

Function Documentation

◆ tRingBuffer_init()

void tRingBuffer_init ( tRingBuffer *const  ring,
int  size,
LEAF *const  leaf 
)

Initialize a tRingBuffer to the default mempool of a LEAF instance.

Parameters
bufferA pointer to the tRingbuffer to initialize.
sizeSize of the buffer. Should be a power of 2. Will otherwise be adjusted to the nearest greater power of 2.
leafA pointer to the leaf instance.

◆ tRingBuffer_initToPool()

void tRingBuffer_initToPool ( tRingBuffer *const  ring,
int  size,
tMempool *const  mempool 
)

Initialize a tRingBuffer to a specified mempool.

Parameters
bufferA pointer to the tRingbuffer to initialize.
sizeSize of the buffer. Should be a power of 2. Will otherwise be adjusted to the nearest greater power of 2.
mempoolA pointer to the tMempool to use.

◆ tRingBuffer_free()

void tRingBuffer_free ( tRingBuffer *const  ring)

Free a tRingBuffer from its mempool.

Parameters
bufferA pointer to the tRingBuffer to free.

◆ tRingBuffer_push()

void tRingBuffer_push ( tRingBuffer *const  ring,
float  val 
)

Push a value to the ring buffer, overwriting the oldest value if the buffer is full.

Parameters
bufferA pointer to the relevant tRingBuffer.
inputThe value to push to the buffer.

◆ tRingBuffer_getNewest()

float tRingBuffer_getNewest ( tRingBuffer *const  ring)

Get the newest value in the ring buffer.

Parameters
bufferA pointer to the relevant tRingBuffer.
Returns
The newest value in the ring buffer.

◆ tRingBuffer_getOldest()

float tRingBuffer_getOldest ( tRingBuffer *const  ring)

Get the oldest value in the ring buffer.

Parameters
bufferA pointer to the relevant tRingBuffer.
Returns
The oldest value in the ring buffer.

◆ tRingBuffer_get()

float tRingBuffer_get ( tRingBuffer *const  ring,
int  index 
)

Get the value at an index of the buffer.

Parameters
bufferA pointer to the relevant tRingBuffer.
indexThe index to access.
Returns
The value at the given index.

◆ tRingBuffer_getSize()

int tRingBuffer_getSize ( tRingBuffer *const  ring)

Get the size of the ring buffer.

Parameters
bufferA pointer to the relevant tRingBuffer.
Returns
The size of the buffer.