synthio: Fix sweep-type pitch bends

The accumulator saturate logic was wrong, and the sweep was never restarted
either
This commit is contained in:
Jeff Epler 2023-05-11 19:13:11 -05:00
parent bc7feb30a5
commit 585b1c23b5
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
2 changed files with 5 additions and 1 deletions

View File

@ -193,6 +193,9 @@ void synthio_note_recalculate(synthio_note_obj_t *self, int32_t sample_rate) {
void synthio_note_start(synthio_note_obj_t *self, int32_t sample_rate) {
synthio_note_recalculate(self, sample_rate);
if (self->bend_mode != SYNTHIO_BEND_MODE_VIBRATO) {
self->bend_state.phase = 0;
}
}
uint32_t synthio_note_envelope(synthio_note_obj_t *self) {

View File

@ -554,8 +554,9 @@ STATIC int synthio_lfo_step_common(synthio_lfo_state_t *state, uint16_t dur) {
return whole_phase;
}
STATIC int synthio_lfo_sweep_common(synthio_lfo_state_t *state, uint16_t dur) {
uint32_t old_phase = state->phase;
uint16_t whole_phase = synthio_lfo_step_common(state, dur);
if (state->phase < state->dds) {
if (state->phase < old_phase) {
state->phase = 0xffffffff;
}
return whole_phase;