Package: libfluidsynth1 Version: 1.1.6-4 Severity: normal Tags: patch When recording, I run JACK with a 192kHz sample rate, to match my audio interface, so as to minimize the cumulative errors through the audio processing chain. Fluidsynth-based instruments appear to work, but produce bad-sounding audio pitched an octave higher than intended. Also, a log message is printed
| fluidsynth: Jack sample rate mismatch, adjusting. (synth.sample-rate=96000, jackd=192000) The underlying cause is that, for some reason, Fluidsynth's `synth.sample-rate' parameter must be between 8kHz and 96kHz, and values beyond these bounds are /silently/ clamped to these bounds. If I start Fluidsynth with `-r192000', then it pretends to accept that, but internally clamps the sample rate to 96kHz. The JACK client code then notices that JACK is really running at 192kHz, prints the message above, and tries to reconfigure the synthesizer's sample rate to 192kHz. Again, this is silently clamped back to 96kHz. In this state, Fluidsynth is essentially writing samples twice as quickly as they should be, resulting in the octave pitch shift I reported. But this also adversely affects the instrument timbre (e.g., violin vibrato is unpleasantly rapid; piano attack sounds like a cheap imitation). My patch just raises the upper sample-rate bound to 192kHz, which is enough for my purposes. With this change, Fluidsynth sounds pretty good agin. I don't know whether the library actually needs an upper bound here at all; if not, it should probably be removed. I've also not done anything about the silent clamping; at least Fluidsynth should print some log message here. This patch applies to current sid (which is also affected). Indeed, I originally fumbled dgit and mistakenly patched sid; so I had to rebase the change, which was trivial. diff --git a/doc/fluidsynth-v10-devdoc.xml b/doc/fluidsynth-v10-devdoc.xml index d20ba1a..47c6d1d 100644 --- a/doc/fluidsynth-v10-devdoc.xml +++ b/doc/fluidsynth-v10-devdoc.xml @@ -235,7 +235,7 @@ saturation of the output when random MIDI files are played.< <row> <entry></entry> <entry>Min-Max</entry> - <entry>22050-96000</entry> + <entry>22050-192000</entry> </row> <row> <entry></entry> diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 381ef80..56ebe1a 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -589,7 +589,7 @@ in rendering-to-file scenarios where underruns is not an iss <tr> <td></td> <td>Min-Max</td> - <td>22050-96000</td> + <td>22050-192000</td> </tr> <tr> <td></td> diff --git a/doc/fluidsynth.1 b/doc/fluidsynth.1 index 389532f..e788a82 100644 --- a/doc/fluidsynth.1 +++ b/doc/fluidsynth.1 @@ -212,7 +212,7 @@ Voice polyphony count (number of simultaneous voices allowed .B synth.reverb.active BOOL [def=True] Reverb effect enable toggle. .TP -.B synth.sample\-rate FLOAT [min=22050.000, max=96000.000, def=44100.000] +.B synth.sample\-rate FLOAT [min=22050.000, max=192000.000, def=44100.000 Synthesizer sample rate. .TP .B synth.threadsafe-api BOOL [def=True] diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 1e782f1..10f579d 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -202,7 +202,7 @@ void fluid_synth_settings(fluid_settings_t* settings) fluid_settings_register_int(settings, "synth.effects-channels", 2, 2, 2, 0, NULL, NULL); fluid_settings_register_num(settings, "synth.sample-rate", - 44100.0f, 8000.0f, 96000.0f, + 44100.0f, 8000.0f, 192000.0f, 0, NULL, NULL); fluid_settings_register_int(settings, "synth.device-id", 0, 0, 126, 0, NULL, NULL); @@ -590,7 +590,7 @@ new_fluid_synth(fluid_settings_t *settings) /* register the callbacks */ fluid_settings_register_num(settings, "synth.sample-rate", - 44100.0f, 8000.0f, 96000.0f, 0, + 44100.0f, 8000.0f, 192000.0f, 0, (fluid_num_update_t) fluid_synth_update_sample_rat fluid_settings_register_num(settings, "synth.gain", 0.2f, 0.0f, 10.0f, 0, @@ -2139,7 +2139,7 @@ fluid_synth_set_sample_rate(fluid_synth_t* synth, float sa int i; fluid_return_if_fail (synth != NULL); fluid_synth_api_enter(synth); - fluid_clip (sample_rate, 8000.0f, 96000.0f); + fluid_clip (sample_rate, 8000.0f, 192000.0f); synth->sample_rate = sample_rate; fluid_settings_getint(synth->settings, "synth.min-note-length", &i); -- System Information: Debian Release: 9.9 APT prefers stable APT policy: (990, 'stable'), (500, 'stable-updates') Architecture: i386 (i686) Foreign Architectures: amd64 Kernel: Linux 4.9.0-8-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8), LANGUAGE=en_GB.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init) Versions of packages libfluidsynth1 depends on: ii libasound2 1.1.3-5 ii libc6 2.24-11+deb9u4 ii libglib2.0-0 2.50.3-2 ii libjack0 [libjack-0.125] 1:0.125.0-2 ii libpulse0 10.0-1+deb9u1 ii libreadline7 7.0-3 ii libsndfile1 1.0.27-3 libfluidsynth1 recommends no packages. libfluidsynth1 suggests no packages. -- no debconf information