lasp/cpp_src/dsp/lasp_timebuffer.h

48 lines
1.1 KiB
C++

#pragma once
#include "lasp_mathtypes.h"
#include <memory>
#include <optional>
class TimeBufferImp;
/**
* @brief Implementation of a buffer of time samples, where
*/
class TimeBuffer {
std::unique_ptr<TimeBufferImp> _imp;
public:
TimeBuffer();
~TimeBuffer();
/**
* @brief Put samples in the buffer. Number of channels should match other
* frames, otherwise things go wrong.
*
* @param mat Samples to push, axes should be as mat(frame, channel).
*/
void push(const dmat &mat);
/**
* @brief Reset (empties) the time buffer.
*/
void reset();
/**
* @brief Returns current size of stored amount of frames.
*
* @return The current amount of frames in the storage
*/
us size() const;
/**
* @brief Pop frames from the buffer. Throws a runtime error if more frames
* are requested than actually stored.
*
* @param nframes The number of rows
* @param keep The number of frames to copy, but also to keep in the buffer
* (usage: overlap)
*
* @return Array time samples for each channel
*/
dmat pop(const us nframes, const us keep = 0);
};