|
bpmdetect 0.8.11
Automatic BPM detection tool
|
#include <sampleringbuffer.h>
Public Member Functions | |
| SampleRingBuffer (std::size_t capacity) | |
| std::size_t | write (std::span< const float > samples) |
| std::size_t | read (std::span< float > destination) |
| void | discardAll () |
Lock-free single-producer, single-consumer ring buffer for audio samples.
The producer (real-time audio thread) only calls write(), and the consumer (worker thread) only calls read() and discardAll(). Writes are all-or-nothing so interleaved frames are never split.
|
explicit |
Constructs a ring buffer holding at least capacity samples (rounded up to a power of two).
| void SampleRingBuffer::discardAll | ( | ) |
Discards all buffered samples. Consumer only.
| std::size_t SampleRingBuffer::read | ( | std::span< float > | destination | ) |
Reads up to destination.size() samples. Returns the number of samples read. Consumer only.
| std::size_t SampleRingBuffer::write | ( | std::span< const float > | samples | ) |
Writes all samples or none if there is not enough space. Returns the number of samples written. Producer only. Real-time safe.