VIANC/pw_plugin/ringbuffer.h

18 lines
507 B
C

#include <cstddef>
#pragma once
struct ringbuffer {
static constexpr size_t bsize = 47*1024*2;
float buffer[bsize]; // Enough for one second of playback
size_t enqueue_time = 0;
size_t dequeue_time = 0;
int w_head_pos = 0; // Next sample is stored there
int r_head_pos = 0; // Next sample is read from there
void enqueue(float* data, size_t nframes);
// Dequeue values, eventually skipping one channel
size_t dequeue(float* data, size_t nframes,
bool left_mask=true, bool right_mask=true);
};