Commit 620af2b3 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Tweak vib and unison more

parent ff80544b
......@@ -56,7 +56,7 @@ io_init(void)
void
clock_init(void)
{
// Run Timer0 (8-bit timer) at F_CPU/256 = 62.5 kHz
// Run Timer0 (8-bit timer) at F_CPU/1024 -- faster incurs roll arounds. Use 16 bit timer?
TCCR0B |= _BV(CS00) | _BV(CS02);
}
......
......@@ -18,15 +18,15 @@ static uint16_t current_bend;
void mono_set_pitch(void);
const float detune_factor[NUM_VOICES] = {
1.5,
-1.5,
0.75,
-0.75,
1.2,
-1.2,
0.6,
-0.6,
};
static uint8_t detune_amount;
static uint8_t mod_wheel;
static uint16_t phase;
static uint32_t phase;
static uint8_t phase_inc;
static int16_t vibrato;
......@@ -127,15 +127,16 @@ mono_update_vibrato(void)
{
int16_t old_vibrato = vibrato;
if (phase < INT16_MAX) {
vibrato = phase - VIB_MID;
uint16_t phase16 = phase >> 16;
if (phase16 < INT16_MAX) {
vibrato = phase16 - VIB_MID;
} else {
vibrato = phase - INT16_MAX;
vibrato = phase16 - INT16_MAX;
vibrato = INT16_MAX - vibrato;
vibrato -= VIB_MID;
}
float pitch_factor = dac_pitch_delta(2) / ((float) INT16_MAX);
float pitch_factor = dac_pitch_delta(7) / ((float) INT16_MAX);
vibrato *= pitch_factor;
float mod_factor = mod_wheel / 127.0;
......@@ -151,7 +152,7 @@ mono_update_vibrato(void)
void
mono_update_clock(uint8_t delta)
{
phase += delta * (1 + phase_inc/3.0);
phase += delta * 4096.0 * (1 + phase_inc);
mono_update_vibrato();
}
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