wip: better samplebuffer filling

master
Clyne 3 years ago
parent b430a38ce5
commit d002746e25

@ -8,7 +8,7 @@ TARGET_PLATFORM = L4
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) ifeq ($(USE_OPT),)
USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nosys.specs USE_OPT = -Os -g3 -ggdb -fomit-frame-pointer -falign-functions=16 --specs=nosys.specs
endif endif
# C specific options here (added to USE_OPT). # C specific options here (added to USE_OPT).

@ -19,17 +19,63 @@ void SampleBuffer::clear() {
} }
__attribute__((section(".convcode"))) __attribute__((section(".convcode")))
void SampleBuffer::modify(Sample *data, unsigned int srcsize) { void SampleBuffer::modify(Sample *data, unsigned int srcsize) {
auto size = srcsize < m_size ? srcsize : m_size; auto size = std::min(srcsize, m_size);
size = (size + 15) & 0xFF0;
m_modified = m_buffer; m_modified = m_buffer;
for (Sample *d = m_buffer, *s = data; s != data + size;) const int *src = reinterpret_cast<const int *>(data);
*d++ = *s++; 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"))) __attribute__((section(".convcode")))
void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) { void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) {
auto size = srcsize < m_size / 2 ? srcsize : m_size / 2; auto size = std::min(srcsize, m_size / 2);
size = (size + 15) & 0xFF0;
m_modified = middata(); m_modified = middata();
for (Sample *d = middata(), *s = data; s != data + size;) const int *src = reinterpret_cast<const int *>(data);
*d++ = *s++; 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() { void SampleBuffer::setModified() {

Loading…
Cancel
Save