From a3e8bd58323f75ffa2458a68c8dff8fc97a10708 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 30 Nov 2019 00:52:50 +0100 Subject: [PATCH] Documented the historical buffer --- src/sfizz/HistoricalBuffer.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/sfizz/HistoricalBuffer.h b/src/sfizz/HistoricalBuffer.h index 5e616b02..1c9ae985 100644 --- a/src/sfizz/HistoricalBuffer.h +++ b/src/sfizz/HistoricalBuffer.h @@ -4,6 +4,12 @@ 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 HistoricalBuffer { public: @@ -14,13 +20,24 @@ public: resize(size); } + /** + * @brief Resize the underlying buffer. Newly added "slots" are + * initialized to 0.0 + * + * @param size + */ void resize(int size) { buffer.resize(size); fill(absl::MakeSpan(buffer), 0.0); index = 0; } - + + /** + * @brief Add a value to the buffer + * + * @param value + */ void push(ValueType value) { if (size > 0) { @@ -30,6 +47,11 @@ public: } } + /** + * @brief Return the average of all the values in the buffer + * + * @return ValueType + */ ValueType getAverage() const { return mean(buffer); @@ -39,4 +61,4 @@ private: size_t size { 0 }; size_t index { 0 }; }; -} \ No newline at end of file +}