3#include "debugtrace.hpp"
11using rte = std::runtime_error;
17 std::deque<arma::rowvec> _storage;
27 if (!_storage.empty()) {
28 if (mat.n_cols != _storage.front().n_cols) {
29 throw rte(
"Invalid number of channels in mat");
33 for (
us i = 0; i < mat.n_rows; i++) {
34 _storage.push_back(mat.row(i));
42 if (keep >= nframes) {
43 throw rte(
"keep should be < nframes");
46 throw rte(
"Requested more than currently in storage");
49 assert(!_storage.empty());
51 dmat res(nframes, _storage.front().n_cols);
54 for (
us i = 0; i < nframes; i++) {
55 if (i + keep < nframes) {
57 res.row(i) = _storage.front();
66 res.row(i) = _storage[j];
84 return _imp->pop(n_rows, keep);
dmat pop(const us nframes, const us keep=0)
Pop frames from the buffer. Throws a runtime error if more frames are requested than actually stored.
us size() const
Returns current size of stored amount of frames.
void reset()
Reset (empties) the time buffer.
void push(const dmat &mat)
Put samples in the buffer. Number of channels should match other frames, otherwise things go wrong.
void push(const dmat &mat)
us n_frames() const
Counts the number of available frames in the queue.
dmat pop(const us nframes, const us keep)
size_t us
We often use boolean values.