aboutsummaryrefslogtreecommitdiffstats
path: root/source/common.hpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2021-01-22 21:43:36 -0500
committerClyne Sullivan <clyne@bitgloo.com>2021-01-22 21:43:36 -0500
commit48026bb824fd2d9cfb00ecd040db6ef3a416bae9 (patch)
treec14713aedfe78ee8b34f2e1252408782e2e2ff5d /source/common.hpp
parente080a26651f90c88176140d63a74c93c2f4041a2 (diff)
upload initial port
Diffstat (limited to 'source/common.hpp')
-rw-r--r--source/common.hpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/source/common.hpp b/source/common.hpp
index 1045b32..f6a8cd0 100644
--- a/source/common.hpp
+++ b/source/common.hpp
@@ -1,20 +1,31 @@
#include <array>
#include <cstdint>
-constexpr unsigned int MAX_SAMPLE_BUFFER_SIZE = 6000;
+//#define ENABLE_SIGGEN
+
+constexpr unsigned int MAX_SAMPLE_BUFFER_SIZE = 4000;
using Sample = uint16_t;
class SampleBuffer
{
public:
+ SampleBuffer(Sample *buffer) :
+ m_buffer(buffer) {}
+
void clear() {
- m_buffer.fill(0);
+ /*static const Sample ref[21] = {
+ 100, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800,
+ 2000, 2200, 2400, 2600, 2800, 3000, 3200, 3400, 3600, 3800, 4095
+ };
+ for (unsigned int i = 0; i < m_size; i++)
+ m_buffer[i] = ref[i % 21];*/
+ std::fill(m_buffer, m_buffer + m_size, 2048);
}
void modify(Sample *data, unsigned int srcsize) {
auto size = srcsize < m_size ? srcsize : m_size;
- std::copy(data, data + size, m_buffer.data());
- m_modified = m_buffer.data();
+ std::copy(data, data + size, m_buffer);
+ m_modified = m_buffer;
}
void midmodify(Sample *data, unsigned int srcsize) {
auto size = srcsize < m_size / 2 ? srcsize : m_size / 2;
@@ -26,14 +37,14 @@ public:
m_size = size < MAX_SAMPLE_BUFFER_SIZE ? size : MAX_SAMPLE_BUFFER_SIZE;
}
- Sample *data() /*const*/ {
- return m_buffer.data();
+ Sample *data() {
+ return m_buffer;
}
- Sample *middata() /*const*/ {
- return m_buffer.data() + m_size / 2;
+ Sample *middata() {
+ return m_buffer + m_size / 2;
}
- uint8_t *bytedata() /*const*/ {
- return reinterpret_cast<uint8_t *>(m_buffer.data());
+ uint8_t *bytedata() {
+ return reinterpret_cast<uint8_t *>(m_buffer);
}
Sample *modified() {
@@ -49,7 +60,8 @@ public:
}
private:
- std::array<Sample, MAX_SAMPLE_BUFFER_SIZE> m_buffer;
+ //std::array<Sample, MAX_SAMPLE_BUFFER_SIZE> m_buffer;
+ Sample *m_buffer = nullptr;
unsigned int m_size = MAX_SAMPLE_BUFFER_SIZE;
Sample *m_modified = nullptr;
};