Commit a5debe96 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Move multiplication into table

parent f060eb8c
......@@ -3,7 +3,7 @@
#include <math.h>
static uint32_t phase;
static uint8_t phase_inc;
static uint8_t rate;
static int16_t vibrato;
static uint8_t depth;
......@@ -19,14 +19,14 @@ void
vibrato_precompute(void)
{
for (uint8_t i = 0; i < NUM_CC; i++) {
exp_table[i] = pow(2, ((float) i * LFO_RANGE) / (NUM_CC - 1));
exp_table[i] = (float) PHASE_MIN_INCR * pow(2, ((float) i * LFO_RANGE) / (NUM_CC - 1));
}
}
void
vibrato_set_rate(uint8_t val)
{
phase_inc = val;
rate = val;
}
void
......@@ -54,7 +54,7 @@ enum {
void
vibrato_update(uint8_t delta)
{
phase += (float) delta * exp_table[phase_inc] * (float) PHASE_MIN_INCR;
phase += delta * exp_table[rate];
uint16_t phase16 = phase >> 16;
if (phase16 < INT16_MAX) {
......
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