aboutsummaryrefslogtreecommitdiffstats
path: root/source/samplebuffer.hpp
diff options
context:
space:
mode:
authorclyne <clyne@bitgloo.com>2021-03-21 16:34:21 -0400
committerGitHub <noreply@github.com>2021-03-21 16:34:21 -0400
commit9b926b81ef1e8a4c7266494ae2a1369380e01b35 (patch)
tree746095fa69eccccdc1c2830fdd0c06bac01848f5 /source/samplebuffer.hpp
parente080a26651f90c88176140d63a74c93c2f4041a2 (diff)
parenta4f1482a8b23d5f761f60d6f3821c84190d89e2f (diff)
Merge pull request #3 from tcsullivan/stm32h7
Stm32h7
Diffstat (limited to 'source/samplebuffer.hpp')
-rw-r--r--source/samplebuffer.hpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/source/samplebuffer.hpp b/source/samplebuffer.hpp
new file mode 100644
index 0000000..6d17d2a
--- /dev/null
+++ b/source/samplebuffer.hpp
@@ -0,0 +1,40 @@
+#ifndef SAMPLEBUFFER_HPP_
+#define SAMPLEBUFFER_HPP_
+
+#include <array>
+#include <cstdint>
+
+using Sample = uint16_t;
+
+constexpr unsigned int MAX_SAMPLE_BUFFER_BYTESIZE = sizeof(Sample) * 8192;
+constexpr unsigned int MAX_SAMPLE_BUFFER_SIZE = MAX_SAMPLE_BUFFER_BYTESIZE / sizeof(Sample);
+
+class SampleBuffer
+{
+public:
+ SampleBuffer(Sample *buffer);
+
+ void clear();
+
+ void modify(Sample *data, unsigned int srcsize);
+ void midmodify(Sample *data, unsigned int srcsize);
+ void setModified();
+ void setMidmodified();
+ Sample *modified();
+
+ Sample *data();
+ Sample *middata();
+ uint8_t *bytedata();
+
+ void setSize(unsigned int size);
+ unsigned int size() const;
+ unsigned int bytesize() const;
+
+private:
+ Sample *m_buffer = nullptr;
+ unsigned int m_size = MAX_SAMPLE_BUFFER_SIZE;
+ Sample *m_modified = nullptr;
+};
+
+#endif // SAMPLEBUFFER_HPP_
+