From 3742e75309dd2ebb24beb8d2a87334df485740be Mon Sep 17 00:00:00 2001 From: rkcf Date: Sat, 25 Feb 2023 14:02:21 -0600 Subject: [PATCH] Add: skeleton wtpp.cpp with Wavetable class Refs: #2 --- src/wtpp.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/wtpp.cpp diff --git a/src/wtpp.cpp b/src/wtpp.cpp new file mode 100644 index 0000000..53c209d --- /dev/null +++ b/src/wtpp.cpp @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include + +static const std::uint_fast32_t DEFAULT_SAMPLE_RATE = 44100; // 44.1 kHz sampling rate +static const std::uint_fast8_t DEFAULT_BIT_DEPTH = 12; + + +class Wavetable +{ +private: + std::uint_fast16_t m_id {}; + std::string m_name {}; + std::array m_table; + +public: + Wavetable(std::uint_fast16_t id, std::string name) + : m_id{ id }, m_name{ name }, m_table {} + { + // Do nothing + } + + std::string name() + { + std::string id_str = std::to_string(m_id); + id_str.append(": "); + id_str.append(m_name); + return id_str; + } +}; + +/* Logs a message */ +static void log(std::string message) +{ + std::cout << "wtpp: " << message << '\n'; +} + +/* Generates basic sine wave table */ +static Wavetable gen_sin_tbl() +{ + Wavetable table = {0, "sine"}; + return table; +} + +int main() +{ + // Generate wavetables + log("Generating wavetables"); + + // Generate sine table + Wavetable sin_tbl = gen_sin_tbl(); + log(sin_tbl.name()); + + return 0; +}