Commit a6c23593 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Move vibrato table to program space

parent 3c09fa75
#include "vibrato.h"
#include "dac.h"
#include "vibrato_rate.h"
#include <avr/pgmspace.h>
static uint32_t phase;
static uint8_t rate;
......@@ -31,7 +32,7 @@ enum { VIB_MID = INT16_MAX >> 1,
void
vibrato_update(uint8_t delta)
{
phase += delta * vibrato_rate_table[rate];
phase += delta * pgm_read_float(&(vibrato_rate_table[rate]));
uint16_t phase16 = phase >> 16;
if (phase16 < INT16_MAX) {
......
......@@ -13,9 +13,10 @@ main(int argc, char **argv)
printf("* Auto-generated by vibrato_rate-gen, do not modify.\n");
printf("* */\n");
printf("\n");
printf("#include <avr/pgmspace.h>\n");
printf("#include \"vibrato_rate.h\"\n");
printf("\n");
printf("float vibrato_rate_table[NUM_CC] = {\n");
printf("const float vibrato_rate_table[NUM_CC] PROGMEM = {\n");
float factor = pow(2, ((float)LFO_RANGE) / (NUM_CC - 1));
float val = PHASE_MIN_INCR;
......
......@@ -3,8 +3,9 @@
* */
#include "vibrato_rate.h"
#include <avr/pgmspace.h>
float vibrato_rate_table[NUM_CC] = {
const float vibrato_rate_table[NUM_CC] PROGMEM = {
20000.000000, 20892.601562, 21825.039062, 22799.091797,
23816.617188, 24879.554688, 25989.929688, 27149.861328,
28361.560547, 29627.337891, 30949.607422, 32330.890625,
......
......@@ -4,6 +4,6 @@
enum { NUM_CC = 128,
};
extern float vibrato_rate_table[NUM_CC];
extern const float vibrato_rate_table[NUM_CC];
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment