parent
7938a3f0ed
commit
b0c352674d
13
src/wave.cpp
13
src/wave.cpp
|
|
@ -1,4 +1,5 @@
|
||||||
#include "wave.h"
|
#include "wave.h"
|
||||||
|
#include "common.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
@ -10,7 +11,15 @@ uint16_t Wave::m_nid = 0;
|
||||||
void Wave::print_head()
|
void Wave::print_head()
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < 3; i++) {
|
for (uint8_t i = 0; i < 3; i++) {
|
||||||
std::cout << m_table[i] << '\n';
|
std::cout << *(m_tp+i) << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Wave::setTable(sample_table_t table)
|
||||||
|
{
|
||||||
|
// Loop through table to load values into sample_table memory
|
||||||
|
for (uint16_t i = 0; i < DEFAULT_N_SAMPLES; i++) {
|
||||||
|
*(m_tp + i) = table[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,7 +36,7 @@ uint8_t Wave::export_csv(std::string path)
|
||||||
|
|
||||||
// put values into file
|
// put values into file
|
||||||
for (uint16_t i = 0; i < DEFAULT_N_SAMPLES; i++) {
|
for (uint16_t i = 0; i < DEFAULT_N_SAMPLES; i++) {
|
||||||
outf << m_table[i] << "\n";
|
outf << *(m_tp+i) << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean exit
|
// Clean exit
|
||||||
|
|
|
||||||
12
src/wave.h
12
src/wave.h
|
|
@ -20,11 +20,15 @@ class Wave
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static uint16_t m_nid; /*!< Unique ID number of NEXT wave */
|
static uint16_t m_nid; /*!< Unique ID number of NEXT wave */
|
||||||
sample_table_t m_table; /*!< Table of sample data */
|
float_t *m_tp; /*!< pointer to first element of sample array */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const uint16_t m_cid; /*!< Unique ID of current wavetable */
|
const uint16_t m_cid; /*!< Unique ID of current wavetable */
|
||||||
Wave() : m_cid(m_nid++) {}
|
Wave() : m_cid(m_nid++)
|
||||||
|
{
|
||||||
|
// Allocate sample memory
|
||||||
|
m_tp = new float_t[DEFAULT_N_SAMPLES];
|
||||||
|
}
|
||||||
|
|
||||||
/*! ID getter */
|
/*! ID getter */
|
||||||
uint16_t getId() { return m_cid; }
|
uint16_t getId() { return m_cid; }
|
||||||
|
|
@ -33,12 +37,12 @@ public:
|
||||||
@param i index of target
|
@param i index of target
|
||||||
@return float_t value at index
|
@return float_t value at index
|
||||||
*/
|
*/
|
||||||
float_t getVal(uint16_t i) { return m_table[i]; }
|
float_t getVal(uint16_t i) { return (*m_tp+i); }
|
||||||
|
|
||||||
/*! Sample data table setter
|
/*! Sample data table setter
|
||||||
@param table Sample data table
|
@param table Sample data table
|
||||||
*/
|
*/
|
||||||
void setTable(sample_table_t table) { m_table = table; }
|
void setTable(sample_table_t table);
|
||||||
|
|
||||||
/*! Prints the first 3 values of sample data */
|
/*! Prints the first 3 values of sample data */
|
||||||
void print_head();
|
void print_head();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue