Class anira::v2::RingBuffer#
-
class RingBuffer#
The 2.x RingBuffer as a view of the anira_ring of one Streamed slot, the float face over the ring accessors of anira/abi/processor.h (anira_ring_*): what a PrePostProcessor’s pre_process pops and its post_process pushes. A view of no ring (the slot of a Static or State tensor) moves nothing and answers 0. Valid for the duration of the phase call that handed it out. Absent from the 2.x class: get_future_sample and get_past_sample (no accessor reads one element; peek_past_block reads the history as a block), get_num_samples (the capacity is anira’s), swap_data, initialize_with_positions and clear_with_positions (anira owns the ring).
[driver-thread] [callback-safe], nonblocking: every method is noexcept and allocates nothing.
Public Functions
-
RingBuffer() noexcept = default#
A view of no ring.
-
inline explicit RingBuffer(anira_ring *ring) noexcept#
-
inline explicit operator bool() const noexcept#
Whether the view has a ring.
-
inline size_t get_num_channels() const noexcept#
The extent of the tensor’s Channel axis, 1 without one; 0 for a view of no ring.
-
inline size_t get_available_samples(size_t channel) const noexcept#
The unread samples of one channel.
-
inline size_t get_available_past_samples(size_t channel) const noexcept#
The consumed samples of one channel the ring still holds as history.
-
inline void push_sample(size_t channel, float sample) noexcept#
-
inline float pop_sample(size_t channel) noexcept#
The oldest unread sample of one channel; 0 when none is available.
-
inline void push_block(size_t channel, const float *data, size_t num_samples) noexcept#
-
inline void pop_block(size_t channel, float *data, size_t num_samples) noexcept#
Pops num_samples samples of one channel, oldest first; those beyond the available ones are zero.
-
inline void peek_past_block(size_t channel, float *data, size_t num_samples) const noexcept#
Copies the num_samples most recently consumed samples of one channel, oldest first, without popping; history the ring never held reads as zero.
-
inline void push_fill(size_t channel, float value, size_t num_samples) noexcept#
-
inline size_t discard(size_t channel, size_t num_samples) noexcept#
Drops up to num_samples unread samples of one channel.
- Returns:
the samples dropped.
-
inline size_t pop_windows(size_t channel, void *data, anira_dtype dtype, size_t num_new, size_t num_old, size_t offset, size_t num_batches) noexcept#
num_batches overlapping windows of one channel, window b at data + offset + b * (num_new
num_old): num_old samples of history, then num_new popped ones.
- Returns:
the elements written, 0 when refused (a dtype that is not the ring’s among them).
-
inline anira_dtype dtype() const noexcept#
The element type of the ring (the Hard contract’s ring dtype, F32 unless declared); 0 for a view of no ring.
-
inline anira_ring *native() const noexcept#
-
RingBuffer() noexcept = default#