Refactor: move Wavetable class to own header

pull/5/head
rkcf 2023-02-26 05:12:15 -06:00
parent e2736eb276
commit 145677f0f2
2 changed files with 29 additions and 23 deletions

28
src/wavetable.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef WAVETABLE_H_
#define WAVETABLE_H_
#include <array>
#include <cstdint>
#include <string>
#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<Wave, DEFAULT_N_SAMPLES> 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<Wave, DEFAULT_N_SAMPLES> table) { m_table = table; }
};
#endif // WAVETABLE_H_

View File

@ -8,33 +8,11 @@
#include <math.h>
#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<Wave, DEFAULT_N_SAMPLES> 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<Wave, DEFAULT_N_SAMPLES> table)
{
m_table = table;
}
};
/* Logs a message */
static void log(std::string message)
{