From 145677f0f26787ed4c0822de4809f3f009dcdad6 Mon Sep 17 00:00:00 2001 From: rkcf Date: Sun, 26 Feb 2023 05:12:15 -0600 Subject: [PATCH] Refactor: move Wavetable class to own header --- src/wavetable.h | 28 ++++++++++++++++++++++++++++ src/wtpp.cpp | 24 +----------------------- 2 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 src/wavetable.h diff --git a/src/wavetable.h b/src/wavetable.h new file mode 100644 index 0000000..d3490f6 --- /dev/null +++ b/src/wavetable.h @@ -0,0 +1,28 @@ +#ifndef WAVETABLE_H_ +#define WAVETABLE_H_ + +#include +#include +#include + +#include "wave.h" + +/* Table of single cycle wave lookup tables */ +class Wavetable { +private: + uint16_t m_id{}; // Unique ID number of wavetable + std::string m_name{}; // String name of wavetable + std::array m_table; // table data + +public: + std::string name() { + std::string id_str = std::to_string(m_id); + id_str.append(": "); + id_str.append(m_name); + return id_str; + } + + void set_table(std::array table) { m_table = table; } +}; + +#endif // WAVETABLE_H_ diff --git a/src/wtpp.cpp b/src/wtpp.cpp index 94bbdf7..503bd5c 100644 --- a/src/wtpp.cpp +++ b/src/wtpp.cpp @@ -8,33 +8,11 @@ #include #include "wave.h" +#include "wavetable.h" static const uint32_t DEFAULT_SAMPLE_RATE = 44100; // 44.1 kHz sampling rate static const uint8_t DEFAULT_BIT_DEPTH = 12; -/* Table of single cycle wave lookup tables */ -class Wavetable -{ -private: - uint16_t m_id {}; // Unique ID number of wavetable - std::string m_name {}; // String name of wavetable - std::array m_table; // table data - -public: - std::string name() - { - std::string id_str = std::to_string(m_id); - id_str.append(": "); - id_str.append(m_name); - return id_str; - } - - void set_table(std::array table) - { - m_table = table; - } -}; - /* Logs a message */ static void log(std::string message) {