Skip to content

Commit 8990c80

Browse files
authored
Merge pull request #572 from shorepine/fix/reset-oscs-before-patch-load
Reset oscs in a synth before loading patch
2 parents 2339c88 + 7d4a30e commit 8990c80

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/patches.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,18 @@ void patches_load_patch(amy_event *e) {
10711071
(int32_t)e->synth, patch_number, (int32_t)e->num_voices, e->voices[0]);
10721072
}
10731073
return;
1074+
} else {
1075+
// Reset every osc belonging to each voice so stale state doesn't persist
1076+
// before we reallocate and reinitialize them below.
1077+
for (uint8_t v = 0; v < num_voices; v++) {
1078+
if (AMY_IS_SET(voice_to_base_osc[voices[v]])) {
1079+
uint16_t base = voice_to_base_osc[voices[v]];
1080+
for (uint16_t j = 0; j < AMY_OSCS - base; j++) {
1081+
if (osc_to_voice[base + j] != voices[v]) break;
1082+
reset_osc(base + j);
1083+
}
1084+
}
1085+
}
10741086
}
10751087

10761088
// At this point, we have the voices[] array and num_voices set up to be initialized.

0 commit comments

Comments
 (0)