From f0b527525fb8280f8964e3e6fee28646beb21ad2 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Thu, 7 May 2020 20:48:08 +0200 Subject: [PATCH] Add implicit conversions to AudioBuffer --- src/sfizz/AudioBuffer.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/sfizz/AudioBuffer.h b/src/sfizz/AudioBuffer.h index 931402de..51500d0a 100644 --- a/src/sfizz/AudioBuffer.h +++ b/src/sfizz/AudioBuffer.h @@ -9,6 +9,7 @@ #include "Config.h" #include "Debug.h" #include "LeakDetector.h" +#include "SIMDHelpers.h" #include "absl/types/span.h" #include "absl/memory/memory.h" #include @@ -259,6 +260,15 @@ public: numChannels = 0; } + /** + * Writes zeros in the buffer + */ + void clear() + { + for (size_t i = 0; i < numChannels; ++i) + fill(getSpan(i), Type{ 0.0 }); + } + /** * @brief Add a positive number of channels to the buffer * @@ -271,6 +281,22 @@ public: addChannel(); } + /** + * @brief Convert implicitly to a pointer of channels + */ + operator const float* const*() const noexcept + { + return buffers.data(); + } + + /** + * @brief Convert implicitly to a pointer of channels + */ + operator float* const*() noexcept + { + return buffers.data(); + } + private: using buffer_type = Buffer; using buffer_ptr = std::unique_ptr;