Documented the historical buffer
This commit is contained in:
parent
4a4790d6ba
commit
a3e8bd5832
1 changed files with 24 additions and 2 deletions
|
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
namespace sfz
|
namespace sfz
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @brief A naive circular buffer which is supposed to hold power values
|
||||||
|
* and return the average of its content.
|
||||||
|
*
|
||||||
|
* @tparam ValueType
|
||||||
|
*/
|
||||||
template<class ValueType>
|
template<class ValueType>
|
||||||
class HistoricalBuffer {
|
class HistoricalBuffer {
|
||||||
public:
|
public:
|
||||||
|
|
@ -14,6 +20,12 @@ public:
|
||||||
resize(size);
|
resize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Resize the underlying buffer. Newly added "slots" are
|
||||||
|
* initialized to 0.0
|
||||||
|
*
|
||||||
|
* @param size
|
||||||
|
*/
|
||||||
void resize(int size)
|
void resize(int size)
|
||||||
{
|
{
|
||||||
buffer.resize(size);
|
buffer.resize(size);
|
||||||
|
|
@ -21,6 +33,11 @@ public:
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add a value to the buffer
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
void push(ValueType value)
|
void push(ValueType value)
|
||||||
{
|
{
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
|
|
@ -30,6 +47,11 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return the average of all the values in the buffer
|
||||||
|
*
|
||||||
|
* @return ValueType
|
||||||
|
*/
|
||||||
ValueType getAverage() const
|
ValueType getAverage() const
|
||||||
{
|
{
|
||||||
return mean<ValueType>(buffer);
|
return mean<ValueType>(buffer);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue