From e2963c9227072384ed805c904300ee308c0674ee Mon Sep 17 00:00:00 2001 From: Stefan Westerfeld Date: Mon, 21 Oct 2019 17:34:44 +0200 Subject: [PATCH] Add new API to release a voice: fluid_synth_release_voice. Signed-off-by: Stefan Westerfeld --- include/fluidsynth/synth.h | 1 + src/synth/fluid_synth.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/fluidsynth/synth.h b/include/fluidsynth/synth.h index efc9bf5f8..f92c7fe73 100644 --- a/include/fluidsynth/synth.h +++ b/include/fluidsynth/synth.h @@ -280,6 +280,7 @@ FLUIDSYNTH_API fluid_voice_t *fluid_synth_alloc_voice(fluid_synth_t *synth, fluid_sample_t *sample, int channum, int key, int vel); FLUIDSYNTH_API void fluid_synth_start_voice(fluid_synth_t *synth, fluid_voice_t *voice); +FLUIDSYNTH_API void fluid_synth_release_voice(fluid_synth_t *synth, fluid_voice_t *voice); FLUIDSYNTH_API void fluid_synth_get_voicelist(fluid_synth_t *synth, fluid_voice_t *buf[], int bufsize, int ID); FLUIDSYNTH_API int fluid_synth_handle_midi_event(void *data, fluid_midi_event_t *event); diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 6a0b280fd..9e5b499d8 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -4456,6 +4456,18 @@ fluid_synth_start_voice(fluid_synth_t *synth, fluid_voice_t *voice) fluid_synth_api_exit(synth); } +void +fluid_synth_release_voice(fluid_synth_t *synth, fluid_voice_t *voice) +{ + fluid_return_if_fail(synth != NULL); + fluid_return_if_fail(voice != NULL); +// fluid_return_if_fail (fluid_synth_is_synth_thread (synth)); + fluid_synth_api_enter(synth); + + fluid_voice_release(voice); + fluid_synth_api_exit(synth); +} + /** * Add a SoundFont loader to the synth. This function takes ownership of \c loader * and frees it automatically upon \c synth destruction.