parent
4a274f4618
commit
e2736eb276
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef WAVE_H_
|
||||
#define WAVE_H_
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
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<float_t, DEFAULT_N_SAMPLES> 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<float_t, DEFAULT_N_SAMPLES> table) {
|
||||
m_table = table;
|
||||
}
|
||||
|
||||
void print_head() {
|
||||
for (uint8_t i = 0; i < 10; i++) {
|
||||
std::cout << m_table[i] << '\n';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // WAVE_H_
|
||||
30
src/wtpp.cpp
30
src/wtpp.cpp
|
|
@ -7,36 +7,10 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#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<float_t, DEFAULT_N_SAMPLES> 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<float_t, DEFAULT_N_SAMPLES> 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue