Relax fluidsynth's sample-rate constraint

Allow for 192kHz session (needs testing, by ear and
by down-sampling to 48k vs. running directly at 48k, etc)
Also prevent plugin from loading when sample-rate is out of bounds.

Previously the plugin loaded but was pitched up when the sample
rate exceeded 96k.
This commit is contained in:
Robin Gareus 2026-01-13 15:00:17 +01:00
parent 54e45ad50c
commit 2a395aead5
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
3 changed files with 30 additions and 2 deletions

View file

@ -223,7 +223,7 @@ void fluid_synth_settings(fluid_settings_t *settings)
fluid_settings_register_int(settings, "synth.audio-groups", 1, 1, 128, 0);
fluid_settings_register_int(settings, "synth.effects-channels", 2, 2, 2, 0);
fluid_settings_register_int(settings, "synth.effects-groups", 1, 1, 128, 0);
fluid_settings_register_num(settings, "synth.sample-rate", 44100.0f, 8000.0f, 96000.0f, 0);
fluid_settings_register_num(settings, "synth.sample-rate", 44100.0f, 8000.0f, 192000.0f, 0);
fluid_settings_register_int(settings, "synth.device-id", 0, 0, 126, 0);
#ifdef ENABLE_MIXER_THREADS
fluid_settings_register_int(settings, "synth.cpu-cores", 1, 1, 256, 0);
@ -3321,7 +3321,7 @@ static void
fluid_synth_set_sample_rate_LOCAL(fluid_synth_t *synth, float sample_rate)
{
int i;
fluid_clip(sample_rate, 8000.0f, 96000.0f);
fluid_clip(sample_rate, 8000.0f, 192000.0f);
synth->sample_rate = sample_rate;
synth->min_note_length_ticks = fluid_synth_get_min_note_length_LOCAL(synth);

View file

@ -416,6 +416,12 @@ instantiate (const LV2_Descriptor* descriptor,
return NULL;
}
if (rate < 8000 || rate > 192000) {
lv2_log_error (&self->logger, "a-fluidsynth.lv2: Sample-rate is out of bounds. Valid range is 8kHz - 192kHz.\n");
free (self);
return NULL;
}
if (!self->schedule) {
lv2_log_error (&self->logger, "a-fluidsynth.lv2: Host does not support worker:schedule\n");
free (self);

View file

@ -405,3 +405,25 @@ index 47f28d2a50..2ef0aee066 100644
{
fluid_tuning_t *tuning;
fluid_real_t x, pitch;
diff --git a/libs/fluidsynth/src/fluid_synth.c b/libs/fluidsynth/src/fluid_synth.c
index 27e7022c5b..fcd4d72645 100644
--- a/libs/fluidsynth/src/fluid_synth.c
+++ b/libs/fluidsynth/src/fluid_synth.c
@@ -223,7 +223,7 @@ void fluid_synth_settings(fluid_settings_t *settings)
fluid_settings_register_int(settings, "synth.audio-groups", 1, 1, 128, 0);
fluid_settings_register_int(settings, "synth.effects-channels", 2, 2, 2, 0);
fluid_settings_register_int(settings, "synth.effects-groups", 1, 1, 128, 0);
- fluid_settings_register_num(settings, "synth.sample-rate", 44100.0f, 8000.0f, 96000.0f, 0);
+ fluid_settings_register_num(settings, "synth.sample-rate", 44100.0f, 8000.0f, 192000.0f, 0);
fluid_settings_register_int(settings, "synth.device-id", 0, 0, 126, 0);
#ifdef ENABLE_MIXER_THREADS
fluid_settings_register_int(settings, "synth.cpu-cores", 1, 1, 256, 0);
@@ -3321,7 +3321,7 @@ static void
fluid_synth_set_sample_rate_LOCAL(fluid_synth_t *synth, float sample_rate)
{
int i;
- fluid_clip(sample_rate, 8000.0f, 96000.0f);
+ fluid_clip(sample_rate, 8000.0f, 192000.0f);
synth->sample_rate = sample_rate;
synth->min_note_length_ticks = fluid_synth_get_min_note_length_LOCAL(synth);