2022-08-11 12:47:44 +00:00
|
|
|
#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();
|
|
|
|
|
|
|
|
/**
|
2022-10-16 19:26:06 +00:00
|
|
|
* @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.
|
2022-08-11 12:47:44 +00:00
|
|
|
*
|
|
|
|
* @param nframes The number of rows
|
|
|
|
* @param keep The number of frames to copy, but also to keep in the buffer
|
|
|
|
* (usage: overlap)
|
|
|
|
*
|
2022-10-16 19:26:06 +00:00
|
|
|
* @return Array time samples for each channel
|
2022-08-11 12:47:44 +00:00
|
|
|
*/
|
2022-10-16 19:26:06 +00:00
|
|
|
dmat pop(const us nframes, const us keep = 0);
|
2022-08-11 12:47:44 +00:00
|
|
|
};
|