aboutsummaryrefslogtreecommitdiffstats
path: root/source/samplebuffer.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2022-04-30 08:41:56 -0400
committerClyne Sullivan <clyne@bitgloo.com>2022-04-30 08:42:45 -0400
commite164629b3839eee0fda0be0e0a9842e78cf02f2b (patch)
treeb72b58665b85a104e5b953af45f00579341b2802 /source/samplebuffer.cpp
parent162dd6de8a0d883962b0b1475f47cbb08e0958d4 (diff)
parent3dd57491b1e81a9d93054eff19ca0e6c65c85b9b (diff)
merge in branch devel
Diffstat (limited to 'source/samplebuffer.cpp')
-rw-r--r--source/samplebuffer.cpp65
1 files changed, 61 insertions, 4 deletions
diff --git a/source/samplebuffer.cpp b/source/samplebuffer.cpp
index 24cc424..74c6778 100644
--- a/source/samplebuffer.cpp
+++ b/source/samplebuffer.cpp
@@ -1,3 +1,14 @@
+/**
+ * @file samplebuffer.cpp
+ * @brief Manages ADC/DAC buffer data.
+ *
+ * Copyright (C) 2021 Clyne Sullivan
+ *
+ * Distributed under the GNU GPL v3 or later. You should have received a copy of
+ * the GNU General Public License along with this program.
+ * If not, see <https://www.gnu.org/licenses/>.
+ */
+
#include "samplebuffer.hpp"
SampleBuffer::SampleBuffer(Sample *buffer) :
@@ -9,16 +20,62 @@ void SampleBuffer::clear() {
__attribute__((section(".convcode")))
void SampleBuffer::modify(Sample *data, unsigned int srcsize) {
auto size = srcsize < m_size ? srcsize : m_size;
+ size = (size + 15) & (~15);
+
m_modified = m_buffer;
- for (Sample *d = m_buffer, *s = data; s != data + size;)
- *d++ = *s++;
+ const int *src = reinterpret_cast<const int *>(data);
+ const int * const srcend = src + (size / 2);
+ int *dst = reinterpret_cast<int *>(m_buffer);
+ do {
+ int a = src[0];
+ int b = src[1];
+ int c = src[2];
+ int d = src[3];
+ int e = src[4];
+ int f = src[5];
+ int g = src[6];
+ int h = src[7];
+ dst[0] = a;
+ dst[1] = b;
+ dst[2] = c;
+ dst[3] = d;
+ dst[4] = e;
+ dst[5] = f;
+ dst[6] = g;
+ dst[7] = h;
+ src += 8;
+ dst += 8;
+ } while (src < srcend);
}
__attribute__((section(".convcode")))
void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) {
auto size = srcsize < m_size / 2 ? srcsize : m_size / 2;
+ size = (size + 15) & (~15);
+
m_modified = middata();
- for (Sample *d = middata(), *s = data; s != data + size;)
- *d++ = *s++;
+ const int *src = reinterpret_cast<const int *>(data);
+ const int * const srcend = src + (size / 2);
+ int *dst = reinterpret_cast<int *>(middata());
+ do {
+ int a = src[0];
+ int b = src[1];
+ int c = src[2];
+ int d = src[3];
+ int e = src[4];
+ int f = src[5];
+ int g = src[6];
+ int h = src[7];
+ dst[0] = a;
+ dst[1] = b;
+ dst[2] = c;
+ dst[3] = d;
+ dst[4] = e;
+ dst[5] = f;
+ dst[6] = g;
+ dst[7] = h;
+ src += 8;
+ dst += 8;
+ } while (src < srcend);
}
void SampleBuffer::setModified() {