]> Nishi Git Mirror - ksynth.git/commitdiff
fixed set_max_polyphony
authornishi <nishi@7b47e76f-e598-2f43-bc14-414d160cc389>
Sat, 15 Jun 2024 14:03:55 +0000 (14:03 +0000)
committernishi <nishi@7b47e76f-e598-2f43-bc14-414d160cc389>
Sat, 15 Jun 2024 14:03:55 +0000 (14:03 +0000)
git-svn-id: file:///raid/svn-main/kazu-ksynth/trunk@47 7b47e76f-e598-2f43-bc14-414d160cc389

src/ksynth.c

index d8e165fa82954cdd55cb8e67934235f573e952bb..514b59a7b774a21bda18834781f97f2dadf296db 100644 (file)
@@ -321,17 +321,18 @@ bool ksynth_set_max_polyphony(struct KSynth* ksynth_instance, unsigned int max_p
        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;