Refactor: move Wavetable class to own header
parent
e2736eb276
commit
145677f0f2
|
|
@ -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_
|
||||||
24
src/wtpp.cpp
24
src/wtpp.cpp
|
|
@ -8,33 +8,11 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "wave.h"
|
#include "wave.h"
|
||||||
|
#include "wavetable.h"
|
||||||
|
|
||||||
static const uint32_t DEFAULT_SAMPLE_RATE = 44100; // 44.1 kHz sampling rate
|
static const uint32_t DEFAULT_SAMPLE_RATE = 44100; // 44.1 kHz sampling rate
|
||||||
static const uint8_t DEFAULT_BIT_DEPTH = 12;
|
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 */
|
/* Logs a message */
|
||||||
static void log(std::string message)
|
static void log(std::string message)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue