From 69e78755c2e6fd3850faae5a7f575d47d81e6408 Mon Sep 17 00:00:00 2001 From: derselbst Date: Thu, 19 Sep 2024 13:06:23 +0200 Subject: [PATCH] Fix clipping for loud OGG samples Fixes #1380 --- src/sfloader/fluid_sffile.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sfloader/fluid_sffile.c b/src/sfloader/fluid_sffile.c index 96d06ceae..83594246d 100644 --- a/src/sfloader/fluid_sffile.c +++ b/src/sfloader/fluid_sffile.c @@ -2500,6 +2500,12 @@ static int fluid_sffile_read_vorbis(SFData *sf, unsigned int start_byte, unsigne goto error_exit; } + // Avoid clipping for loud samples, see + // https://github.com/FluidSynth/fluidsynth/issues/1380 + // and + // https://github.com/libsndfile/libsndfile/issues/194 + sf_command(sndfile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE); + /* Automatically decompresses the Ogg Vorbis data to 16-bit PCM */ if(sf_readf_short(sndfile, wav_data, sfinfo.frames) < sfinfo.frames) {