From 3cc6970596d943bafbb05aca613c29388b42c7ca Mon Sep 17 00:00:00 2001 From: rkcf Date: Sun, 26 Feb 2023 03:53:50 -0600 Subject: [PATCH] Refactor: simplify number typedefs --- src/wtpp.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/wtpp.cpp b/src/wtpp.cpp index 3c73dfb..c17efbd 100644 --- a/src/wtpp.cpp +++ b/src/wtpp.cpp @@ -7,20 +7,20 @@ #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; -static const std::uint_fast16_t DEFAULT_N_SAMPLES = 1024; +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; class Wavetable { private: - std::uint_fast16_t m_id {}; // Unique ID number of wavetable + uint_fast16_t m_id {}; // Unique ID number of wavetable std::string m_name {}; // String name of wavetable - std::array m_table; // table data + std::array m_table; // table data public: - Wavetable(std::uint_fast16_t id, std::string name) + Wavetable(uint16_t id, std::string name) : m_id{ id }, m_name{ name }, m_table {} { // Do nothing @@ -34,14 +34,14 @@ public: return id_str; } - void set_table(std::array table) + void set_table(std::array table) { m_table = table; } void print_head() { - for(std::uint_fast8_t i = 0; i < 10; i++) { + for(uint8_t i = 0; i < 10; i++) { std::cout << m_table[i] << '\n'; } } @@ -59,12 +59,12 @@ static Wavetable gen_sin_tbl() // Make the new Wavetable object Wavetable table = {0, "sine"}; // Make an array to hold our values - std::array sin_vals {}; + std::array sin_vals {}; // Make a place to store calculated value - std::float_t val = 0; + float_t val = 0; // Loop through number of samples and set table values - for (std::uint_fast16_t i = 0; i < DEFAULT_N_SAMPLES; i++) { + for (uint16_t i = 0; i < DEFAULT_N_SAMPLES; i++) { // Calculate the value of sin at position val = std::sin((2 * M_PI * i) / DEFAULT_N_SAMPLES); sin_vals[i] = val;