diff --git a/src/wave.h b/src/wave.h index f1f6b93..d6d75a1 100644 --- a/src/wave.h +++ b/src/wave.h @@ -1,3 +1,6 @@ +/*! @file wave.h + @brief Header for Wave class and associated Wave functions + */ #ifndef WAVE_H_ #define WAVE_H_ @@ -8,21 +11,34 @@ const uint16_t DEFAULT_N_SAMPLES = 1024; -/* Single cycle wave object with lookup table */ +using sample_table_t = std::array; + +/*! @class Wave wave.h "wave.h" + @brief 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 + uint16_t m_id{}; /*!< Unique ID number of wave */ + sample_table_t m_table; /*!< Table of sample data */ + public: Wave(uint16_t id) : m_id{id}, m_table{} { /* Do nothing */ } + /*! ID getter */ uint16_t id() { return m_id; } - void setTable(std::array table) { m_table = table; } + /*! Sample data table setter + @param table Sample data table + */ + void setTable(sample_table_t table) { m_table = table; } + /*! Prints the first 10 values of sample data */ void print_head(); }; +/*! Generate sine wave data + @return a table of values + */ Wave gen_sin(); #endif // WAVE_H_ diff --git a/src/wavetable.h b/src/wavetable.h index 2e75ba9..f44cdc9 100644 --- a/src/wavetable.h +++ b/src/wavetable.h @@ -1,3 +1,6 @@ +/*! @file wavetable.h + @brief Header for Wavetable class and associated table functions + */ #ifndef WAVETABLE_H_ #define WAVETABLE_H_ @@ -7,17 +10,29 @@ #include "wave.h" -/* Table of single cycle wave lookup tables */ +const uint8_t DEFAULT_N_WAVES = 256; + +using wave_table_t = std::array; + +/*! @class Wavetable wavetable.h "wavetable.h" + @brief Object containing a table of single cycle Wave objects + */ 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 +private: + uint16_t m_id{}; /*!< Unique ID number of wavetable */ + std::string m_name{}; /*!< String name of wavetable */ + wave_table_t m_table; /*!< Table of Wave objects */ public: + /*! Makes formatted name and id string + @return a formatted string in the form "id: name" + */ std::string name(); - void set_table(std::array table) { m_table = table; } + /*! setter for wave table + @param table Table of Wave objects + */ + void set_table(wave_table_t table) { m_table = table; } }; #endif // WAVETABLE_H_ diff --git a/src/wtpp.cpp b/src/wtpp.cpp index b399154..bb72a54 100644 --- a/src/wtpp.cpp +++ b/src/wtpp.cpp @@ -13,7 +13,9 @@ static const uint32_t DEFAULT_SAMPLE_RATE = 44100; // 44.1 kHz sampling rate static const uint8_t DEFAULT_BIT_DEPTH = 12; -/* Logs a message */ +/*! Logs a message + @param message The string to be logged + */ static void log(std::string message) { std::cout << "wtpp: " << message << '\n';