diff --git a/fluidsynth/src/fluid_chan.h b/fluidsynth/src/fluid_chan.h index a286465f..610e7a55 100644 --- a/fluidsynth/src/fluid_chan.h +++ b/fluidsynth/src/fluid_chan.h @@ -139,5 +139,7 @@ int fluid_channel_get_interp_method(fluid_channel_t* chan); #define fluid_channel_set_gen(_c, _n, _v, _a) { (_c)->gen[_n] = _v; (_c)->gen_abs[_n] = _a; } #define fluid_channel_get_gen(_c, _n) ((_c)->gen[_n]) #define fluid_channel_get_gen_abs(_c, _n) ((_c)->gen_abs[_n]) +#define fluid_channel_get_min_note_length_ticks(chan) \ + ((chan)->synth->min_note_length_ticks) #endif /* _FLUID_CHAN_H */ diff --git a/fluidsynth/src/fluid_synth.c b/fluidsynth/src/fluid_synth.c index 2222ae86..9f7a70f6 100644 --- a/fluidsynth/src/fluid_synth.c +++ b/fluidsynth/src/fluid_synth.c @@ -254,7 +254,7 @@ void fluid_synth_settings(fluid_settings_t* settings) fluid_settings_add_option(settings, "synth.midi-mode-lock", "no"); fluid_settings_add_option(settings, "synth.midi-mode-lock", "yes"); - fluid_settings_register_int(settings, "synth.min-note-length", 0, 0, 65536, 0, NULL, NULL); + fluid_settings_register_int(settings, "synth.min-note-length", 10, 0, 65535, 0, NULL, NULL); } /* @@ -1411,7 +1411,7 @@ fluid_synth_noteoff_LOCAL(fluid_synth_t* synth, int chan, int key) used_voices); } /* if verbose */ - fluid_voice_noteoff(voice, synth->min_note_length_ticks); + fluid_voice_noteoff(voice); status = FLUID_OK; } /* if voice on */ } /* for all voices */ @@ -1429,7 +1429,7 @@ fluid_synth_damp_voices_LOCAL(fluid_synth_t* synth, int chan) voice = synth->voice[i]; if ((voice->chan == chan) && _SUSTAINED(voice)) - fluid_voice_noteoff(voice, synth->min_note_length_ticks); + fluid_voice_noteoff(voice); } return FLUID_OK; @@ -2013,7 +2013,7 @@ fluid_synth_all_notes_off_LOCAL(fluid_synth_t* synth, int chan) voice = synth->voice[i]; if (_PLAYING(voice) && (voice->chan == chan)) - fluid_voice_noteoff(voice, synth->min_note_length_ticks); + fluid_voice_noteoff(voice); } return FLUID_OK; } @@ -4692,7 +4692,7 @@ fluid_synth_release_voice_on_same_note_LOCAL(fluid_synth_t* synth, int chan, && (voice->chan == chan) && (voice->key == key) && (fluid_voice_get_id(voice) != synth->noteid)) { - fluid_voice_noteoff(voice, synth->min_note_length_ticks); + fluid_voice_noteoff(voice); } } } @@ -5750,7 +5750,7 @@ fluid_synth_stop_LOCAL (fluid_synth_t *synth, unsigned int id) voice = synth->voice[i]; if (_ON(voice) && (fluid_voice_get_id (voice) == id)) - fluid_voice_noteoff(voice, synth->min_note_length_ticks); + fluid_voice_noteoff(voice); } } diff --git a/fluidsynth/src/fluid_voice.c b/fluidsynth/src/fluid_voice.c index c5455cb5..55bf2e1a 100644 --- a/fluidsynth/src/fluid_voice.c +++ b/fluidsynth/src/fluid_voice.c @@ -266,7 +266,7 @@ fluid_voice_write (fluid_voice_t* voice, fluid_real_t *dsp_buf) if (voice->noteoff_ticks != 0 && voice->ticks >= voice->noteoff_ticks) { - fluid_voice_noteoff(voice, 0); + fluid_voice_noteoff(voice); } fluid_check_fpe ("voice_write startup"); @@ -1557,14 +1557,14 @@ int fluid_voice_modulate_all(fluid_voice_t* voice) /* * fluid_voice_noteoff - * @param at_tick minimum amount of ticks (samples) when the note - * is turned off. */ int -fluid_voice_noteoff(fluid_voice_t* voice, unsigned int at_tick) +fluid_voice_noteoff(fluid_voice_t* voice) { fluid_profile(FLUID_PROF_VOICE_NOTE, voice->ref); + unsigned int at_tick = fluid_channel_get_min_note_length_ticks(voice->channel); + if (at_tick > voice->ticks) { /* Delay noteoff */ voice->noteoff_ticks = at_tick; diff --git a/fluidsynth/src/fluid_voice.h b/fluidsynth/src/fluid_voice.h index 1ff8b4a1..e5ebdff4 100644 --- a/fluidsynth/src/fluid_voice.h +++ b/fluidsynth/src/fluid_voice.h @@ -244,7 +244,7 @@ int fluid_voice_set_gain(fluid_voice_t* voice, fluid_real_t gain); function.*/ void fluid_voice_update_param(fluid_voice_t* voice, int gen); -int fluid_voice_noteoff(fluid_voice_t* voice, unsigned int at_tick); +int fluid_voice_noteoff(fluid_voice_t* voice); int fluid_voice_off(fluid_voice_t* voice); void fluid_voice_mix (fluid_voice_t *voice, fluid_real_t* left_buf, fluid_real_t* right_buf,