Skip to content

daisy::RingBuffer

Module: LIBDAISY / UTILITY

More...

#include <ringbuffer.h>

Public Functions

Name
RingBuffer()
void Init()
size_t capacity() const
size_t writable() const
size_t readable() const
bool isEmpty() const
void Write(T v)
void Overwrite(T v)
T Read()
T ImmediateRead()
void Flush()
void Swallow(size_t n)
void ImmediateRead(T * destination, size_t num_elements)
void Overwrite(const T * source, size_t num_elements)
void Advance(size_t num_elements)
T * GetMutableBuffer()

Detailed Description

template <typename T ,
size_t size>
class daisy::RingBuffer;

Utility Ring Buffer

imported from pichenettes/stmlib

Public Functions Documentation

function RingBuffer

inline RingBuffer()

function Init

inline void Init()

Initializes the Ring Buffer


function capacity

inline size_t capacity() const

Return: The total size of the ring buffer


function writable

inline size_t writable() const

Return: the number of samples that can be written to ring buffer without overwriting unread data.


function readable

inline size_t readable() const

Return: number of unread elements in ring buffer


function isEmpty

inline bool isEmpty() const

Return: True, if the buffer is empty.


function Write

inline void Write(
    T v
)

Parameters:

  • v Value to write

Writes the value to the next available position in the ring buffer


function Overwrite

inline void Overwrite(
    T v
)

Parameters:

  • v Value to overwrite

Writes the new element to the ring buffer, overwriting unread data if necessary.


function Read

inline T Read()

Return: read value

Reads the first available element from the ring buffer


function ImmediateRead

inline T ImmediateRead()

Return: read value

Reads next element from ring buffer immediately


function Flush

inline void Flush()

Flushes unread elements from the ring buffer


function Swallow

inline void Swallow(
    size_t n
)

Parameters:

  • n Size of T ?

Read enough samples to make it possible to read 1 sample.


function ImmediateRead

inline void ImmediateRead(
    T * destination,
    size_t num_elements
)

Parameters:

  • destination buffer to write to
  • num_elements number of elements in buffer

Reads a number of elements into a buffer immediately


function Overwrite

inline void Overwrite(
    const T * source,
    size_t num_elements
)

Parameters:

  • source Input buffer
  • num_elements Number of elements in source

Overwrites a number of elements using the source buffer as input.


function Advance

inline void Advance(
    size_t num_elements
)

Advances the write pointer, for when a peripheral is writing to the buffer.


function GetMutableBuffer

inline T * GetMutableBuffer()

Returns a pointer to the actual Ring Buffer Useful for when a peripheral needs direct access to the buffer.

---

Updated on 2024-01-03 at 19:41:01 +0000