unison key stack fix

master
vampirefrog 6 years ago
parent dc8021056f
commit 9ac8d4ca42

@ -11,7 +11,6 @@ void envelope_init(struct Envelope *env) {
envelope_set_sustain_level(env, 1.0);
envelope_set_target_ratio_a(env, 0.3);
envelope_set_target_ratio_dr(env, 0.0001);
printf("envelope_init()\n");
}
void envelope_reset(struct Envelope *env) {

@ -4,7 +4,7 @@ osc_env.decay 0
osc_env.sustain .4
osc_env.release 0
filter_env.attack 100
filter_env.decay 40000
filter_env.decay 50000
filter_env.sustain 0
filter_env.release 100
filter_eg_intensity 1

@ -134,7 +134,16 @@ static void synth_note_off_monophonic(struct Synth *synth) {
void synth_note_off(struct Synth *synth, uint8_t note, uint8_t velocity) {
if(synth->monophonic) {
if(synth->key_stack_size > 1) {
synth_note_on_monophonic(synth, synth->key_stack[synth->key_stack_size - 2].note, synth->key_stack[synth->key_stack_size - 2].velocity);
if(synth->key_stack[synth->key_stack_size - 1].note == note) {
synth_note_on_monophonic(synth, synth->key_stack[synth->key_stack_size - 2].note, synth->key_stack[synth->key_stack_size - 2].velocity);
} else {
for(int i = 0; i < synth->key_stack_size - 1; i++) {
if(synth->key_stack[i].note == note) {
memmove(synth->key_stack + i, synth->key_stack + i + 1, sizeof(synth->key_stack[0]) * (synth->key_stack_size - i - 1));
break;
}
}
}
} else {
synth_note_off_monophonic(synth);
}

Loading…
Cancel
Save