From 4af400141af0c97c4e4bcd47acf78107a17eafbe Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 3 Jan 2025 10:31:38 +0100 Subject: Separated class files --- ClickStream.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ClickStream.h (limited to 'ClickStream.h') diff --git a/ClickStream.h b/ClickStream.h new file mode 100644 index 0000000..c94f8de --- /dev/null +++ b/ClickStream.h @@ -0,0 +1,57 @@ +#pragma once + +#include "config.h" + +#include + +#include +#include +#include + +class ClickStream +{ +public: + ClickStream(): m_phase(1000000) + { + std::string data_s = Reichwein::File::getFile("media/click.s16le"); + m_data.resize(data_s.size() / 2); // src is in bytes + memcpy(m_data.data(), data_s.data(), data_s.size()); + } + + // generate 1 buffer size + void generate() + { + int i; + size_t j = m_phase; + + for (i = 0; i < nframes; i++) { + if (j >= m_data.size()) + { + buffer[i] = 0; + } + else + { + buffer[i] = m_data[j]; + } + j++; + } + + m_phase = j; + } + + void click() + { + m_phase = 0; + } + + int16_t* get_buffer() + { + return buffer; + } + +private: + std::vector m_data; + size_t m_phase; + int16_t buffer[nframes]; +}; + -- cgit v1.2.3