struct Voice** old_ptr = ksynth_instance->voices;
unsigned long old_count = ksynth_instance->max_polyphony;
+ ksynth_instance->max_polyphony = max_polyphony;
struct Voice** new_ptr = int_allocate_voices(ksynth_instance);
if(new_ptr != NULL) {
- ksynth_note_off_all(ksynth_instance);
-
ksynth_instance->voices = new_ptr;
- ksynth_instance->max_polyphony = max_polyphony;
+
+ ksynth_note_off_all(ksynth_instance);
int_free_voices(old_ptr, old_count);
return true;
}
+ ksynth_instance->max_polyphony = old_count;
fprintf(stderr, "[KSynth] Error: Failed to allocate memory for voices.\n");
return false;