Commit 959ecd1d authored by Jacob Vosmaer's avatar Jacob Vosmaer

Add pitch bend to poly mode

parent 4ca833a2
......@@ -15,7 +15,7 @@ static struct list notes = {
static uint16_t current_bend;
void set_pitch(uint8_t n);
void mono_set_pitch(uint8_t n);
const uint8_t detune_factor[NUM_VOICES] = {
10,
......@@ -42,14 +42,14 @@ mono_note_on(uint8_t n)
l_push(&notes, n);
set_pitch(n);
mono_set_pitch(n);
for (uint8_t v = 0; v < NUM_VOICES; v++) {
gate_on(v);
}
}
void
set_pitch(uint8_t n)
mono_set_pitch(uint8_t n)
{
for (uint8_t v = 0; v < NUM_VOICES; v++) {
dac_set_note2(v, n, (detune_factor[v] * detune_amount)/128, current_bend);
......@@ -72,7 +72,7 @@ mono_note_off(uint8_t n)
return;
}
set_pitch(l_first(&notes));
mono_set_pitch(l_first(&notes));
}
#define CC_DETUNE 14
......@@ -84,7 +84,7 @@ mono_control_change(uint8_t ctl, uint8_t val)
detune_amount = val;
if (!l_empty(&notes)) {
set_pitch(l_first(&notes));
mono_set_pitch(l_first(&notes));
}
}
}
......@@ -95,6 +95,6 @@ mono_pitch_bend(uint16_t bend)
current_bend = bend;
if (!l_empty(&notes)) {
set_pitch(l_first(&notes));
mono_set_pitch(l_first(&notes));
}
}
......@@ -3,13 +3,21 @@
#include "gate.h"
#include "voice.h"
static uint8_t notes[NUM_VOICES];
static uint16_t current_bend;
void
poly_init(void)
{
voice_init();
current_bend = BEND_CENTER;
}
static uint8_t notes[NUM_VOICES];
void
poly_set_pitch(uint8_t v, uint8_t note)
{
dac_set_note2(v, note, 0, current_bend);
}
void
poly_note_on(uint8_t note)
......@@ -20,7 +28,7 @@ poly_note_on(uint8_t note)
return;
}
dac_set_note(v, note);
poly_set_pitch(v, note);
gate_on(v);
notes[v] = note;
}
......@@ -45,5 +53,8 @@ poly_control_change(uint8_t ctl, uint8_t val)
void
poly_pitch_bend(uint16_t bend)
{
// do nothing
current_bend = bend;
for (uint8_t v = 0; v < NUM_VOICES; v++) {
poly_set_pitch(v, notes[v]);
}
}
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