Skip to content

Commit 585b1c2

Browse files
committed
synthio: Fix sweep-type pitch bends
The accumulator saturate logic was wrong, and the sweep was never restarted either
1 parent bc7feb3 commit 585b1c2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

shared-module/synthio/Note.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ void synthio_note_recalculate(synthio_note_obj_t *self, int32_t sample_rate) {
193193

194194
void synthio_note_start(synthio_note_obj_t *self, int32_t sample_rate) {
195195
synthio_note_recalculate(self, sample_rate);
196+
if (self->bend_mode != SYNTHIO_BEND_MODE_VIBRATO) {
197+
self->bend_state.phase = 0;
198+
}
196199
}
197200

198201
uint32_t synthio_note_envelope(synthio_note_obj_t *self) {

shared-module/synthio/__init__.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,9 @@ STATIC int synthio_lfo_step_common(synthio_lfo_state_t *state, uint16_t dur) {
554554
return whole_phase;
555555
}
556556
STATIC int synthio_lfo_sweep_common(synthio_lfo_state_t *state, uint16_t dur) {
557+
uint32_t old_phase = state->phase;
557558
uint16_t whole_phase = synthio_lfo_step_common(state, dur);
558-
if (state->phase < state->dds) {
559+
if (state->phase < old_phase) {
559560
state->phase = 0xffffffff;
560561
}
561562
return whole_phase;

0 commit comments

Comments
 (0)