Skip to content

Commit

Permalink
add fluid_synth_all_notes_release
Browse files Browse the repository at this point in the history
put all relevant notes into release phase, regardless of sustain or sostenuto
  • Loading branch information
albedozero authored Sep 15, 2021
1 parent cedfb64 commit 03c07c4
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/synth/fluid_synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,8 @@ fluid_synth_sysex_xg(fluid_synth_t *synth, const char *data, int len,
}

/**
* Turn off all voices that are playing on the given MIDI channel, by putting them into release phase.
* Turn off all voices that are playing on the given MIDI channel, by putting them into release phase,
* pending their status in SUSTAIN or SOSTENUTO state.
* @param synth FluidSynth instance
* @param chan MIDI channel number (0 to MIDI channel count - 1), (chan=-1 selects all channels)
* @return #FLUID_OK on success, #FLUID_FAILED otherwise
Expand Down Expand Up @@ -2588,6 +2589,32 @@ fluid_synth_all_sounds_off_LOCAL(fluid_synth_t *synth, int chan)
return FLUID_OK;
}

/**
* Turn off all voices that are playing on the given MIDI channel, by putting them into release phase
* regardless of their status in SUSTAIN or SOSTENUTO state.
* @param synth FluidSynth instance
* @param chan MIDI channel number (0 to MIDI channel count - 1), (chan=-1 selects all channels)
* @return #FLUID_OK on success, #FLUID_FAILED otherwise
*/
int
fluid_synth_all_notes_release(fluid_synth_t *synth, int chan)
{
fluid_voice_t *voice;
int i;

for(i = 0; i < synth->polyphony; i++)
{
voice = synth->voice[i];

if(fluid_voice_is_playing(voice) && ((-1 == chan) || (chan == fluid_voice_get_channel(voice))))
{
fluid_voice_release(voice);
}
}

return FLUID_OK;
}

/**
* Reset reverb engine
* @param synth FluidSynth instance
Expand Down

0 comments on commit 03c07c4

Please sign in to comment.