diff --git a/src/wave.h b/src/wave.h new file mode 100644 index 0000000..8398157 --- /dev/null +++ b/src/wave.h @@ -0,0 +1,35 @@ +#ifndef WAVE_H_ +#define WAVE_H_ + +#include +#include +#include + +#include + +const uint16_t DEFAULT_N_SAMPLES = 1024; + +/* Single cycle wave object with lookup table */ +class Wave { +private: + uint16_t m_id{}; // Unique ID number of wave + std::array m_table; // table data +public: + Wave(uint16_t id) : m_id{id}, m_table{} { + // Do nothing + } + + uint16_t id() { return m_id; } + + void set_table(std::array table) { + m_table = table; + } + + void print_head() { + for (uint8_t i = 0; i < 10; i++) { + std::cout << m_table[i] << '\n'; + } + } +}; + +#endif // WAVE_H_ diff --git a/src/wtpp.cpp b/src/wtpp.cpp index 379f290..94bbdf7 100644 --- a/src/wtpp.cpp +++ b/src/wtpp.cpp @@ -7,36 +7,10 @@ #include +#include "wave.h" + static const uint32_t DEFAULT_SAMPLE_RATE = 44100; // 44.1 kHz sampling rate static const uint8_t DEFAULT_BIT_DEPTH = 12; -static const uint16_t DEFAULT_N_SAMPLES = 1024; - -/* Single cycle wave object with lookup table */ -class Wave -{ -private: - uint16_t m_id{}; // Unique ID number of wave - std::array m_table; // table data -public: - Wave(uint16_t id) : m_id{id}, m_table{} - { - // Do nothing - } - - uint16_t id() { - return m_id; - } - - void set_table(std::array table) { - m_table = table; - } - - void print_head() { - for (uint8_t i = 0; i < 10; i++) { - std::cout << m_table[i] << '\n'; - } - } -}; /* Table of single cycle wave lookup tables */ class Wavetable