Add implicit conversions to AudioBuffer

This commit is contained in:
Paul Ferrand 2020-05-07 20:48:08 +02:00
parent 2fcd231062
commit f0b527525f

View file

@ -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 <array>
@ -259,6 +260,15 @@ public:
numChannels = 0;
}
/**
* Writes zeros in the buffer
*/
void clear()
{
for (size_t i = 0; i < numChannels; ++i)
fill<Type>(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<Type, Alignment>;
using buffer_ptr = std::unique_ptr<buffer_type>;