Fix: change waveform generation values to be in range, fixes #6

Refs: #6
pull/13/head
rkcf 2023-02-27 02:24:37 -06:00
parent a7ce35791f
commit 33b615261f
1 changed files with 4 additions and 4 deletions

View File

@ -27,7 +27,7 @@ sample_table_t gen_squ()
if (i < (DEFAULT_N_SAMPLES / 2)) { if (i < (DEFAULT_N_SAMPLES / 2)) {
squ_vals[i] = 1; squ_vals[i] = 1;
} else { } else {
squ_vals[i] = 0; squ_vals[i] = -1;
} }
} }
@ -38,7 +38,7 @@ sample_table_t gen_saw()
{ {
sample_table_t saw_vals = {0}; sample_table_t saw_vals = {0};
float_t step = 2.0 / DEFAULT_N_SAMPLES; // calculate our incremental step size float_t step = 2.0 / DEFAULT_N_SAMPLES; // calculate our incremental step size
float_t val = 0; // place to store calculate value float_t val = -1; // place to store calculate value
// Start low go high [0, 1] // Start low go high [0, 1]
for (uint16_t i = 0; i < DEFAULT_N_SAMPLES; i++) { for (uint16_t i = 0; i < DEFAULT_N_SAMPLES; i++) {
@ -54,9 +54,9 @@ sample_table_t gen_tri()
sample_table_t tri_vals = {0}; sample_table_t tri_vals = {0};
uint16_t half_samples = DEFAULT_N_SAMPLES / 2; uint16_t half_samples = DEFAULT_N_SAMPLES / 2;
float_t step = 2.0 / half_samples; // calculate our incremental step size float_t step = 2.0 / half_samples; // calculate our incremental step size
float_t val = 0; // place to store calculate value float_t val = -1; // place to store calculate value
// Start low go high then low [0, 1, 0] // Start low go high then low [-1, 1, -1]
for (uint16_t i = 0; i < DEFAULT_N_SAMPLES; i++) { for (uint16_t i = 0; i < DEFAULT_N_SAMPLES; i++) {
tri_vals[i] = val; tri_vals[i] = val;
if (i < half_samples) { if (i < half_samples) {