Update to FluidSynth v2.1.8

This commit is contained in:
Dale Whinham committed 2021-03-19 23:53:26 +00:00
1 parent aa30752d74
commit 4840ee1419
6 files changed
+6 -183

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update to circle-stdlib v15.6/Circle Step 43.3.
- Update to inih r52.
- Update to FluidSynth v2.1.8.
- Update ARM toolchains to 10.2-2020.11.
- Config file options are now case-insensitive.
+2 -6
View File
@@ -66,9 +66,7 @@ $(MT32EMUBUILDDIR)/.done: $(CIRCLESTDLIBHOME)/.done
fluidsynth: $(FLUIDSYNTHBUILDDIR)/.done
$(FLUIDSYNTHBUILDDIR)/.done: $(CIRCLESTDLIBHOME)/.done
@patch -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.7-circle.patch
@patch -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.7-pan-fix-1.patch
@patch -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.7-pan-fix-2.patch
@patch -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.8-circle.patch
@export CFLAGS="$(CFLAGS_FOR_TARGET)"
@cmake -B $(FLUIDSYNTHBUILDDIR) \
@@ -123,9 +121,7 @@ veryclean: clean
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(CIRCLEHOME) < patches/circle-43.3-usb-fix-hard-errors.patch
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(CIRCLEHOME) < patches/circle-43.3-pi4-usb-fix.patch
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(CIRCLEHOME) < patches/circle-43.3-minimal-usb-drivers.patch
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.7-circle.patch
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.7-pan-fix-2.patch
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.7-pan-fix-1.patch
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.8-circle.patch
# Clean circle-stdlib
@$(MAKE) -C $(CIRCLESTDLIBHOME) mrproper
-106
View File
@@ -1,106 +0,0 @@
From c4a36c284c96fc6d7454384511a476bd9232a9b8 Mon Sep 17 00:00:00 2001
From: derselbst <tom.mbrt@googlemail.com>
Date: Sat, 6 Feb 2021 15:26:25 +0100
Subject: [PATCH] Avoid audible clicks when rapidly chaning panning
---
src/rvoice/fluid_rvoice.c | 5 +++--
src/rvoice/fluid_rvoice.h | 10 ++++++++--
src/rvoice/fluid_rvoice_mixer.c | 22 +++++++++++++++++++---
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/src/rvoice/fluid_rvoice.c b/src/rvoice/fluid_rvoice.c
index 8837e4415..5f54c33b1 100644
--- a/src/rvoice/fluid_rvoice.c
+++ b/src/rvoice/fluid_rvoice.c
@@ -493,7 +493,8 @@ fluid_rvoice_buffers_check_bufnum(fluid_rvoice_buffers_t *buffers, unsigned int
for(i = buffers->count; i <= bufnum; i++)
{
- buffers->bufs[i].amp = 0.0f;
+ buffers->bufs[i].target_amp = 0.0f;
+ buffers->bufs[i].current_amp = 0.0f;
}
buffers->count = bufnum + 1;
@@ -512,7 +513,7 @@ DECLARE_FLUID_RVOICE_FUNCTION(fluid_rvoice_buffers_set_amp)
return;
}
- buffers->bufs[bufnum].amp = value;
+ buffers->bufs[bufnum].target_amp = value;
}
DECLARE_FLUID_RVOICE_FUNCTION(fluid_rvoice_buffers_set_mapping)
diff --git a/src/rvoice/fluid_rvoice.h b/src/rvoice/fluid_rvoice.h
index 56cd53f46..610afd725 100644
--- a/src/rvoice/fluid_rvoice.h
+++ b/src/rvoice/fluid_rvoice.h
@@ -143,8 +143,14 @@ struct _fluid_rvoice_buffers_t
unsigned int count; /* Number of records in "bufs" */
struct
{
- fluid_real_t amp;
- int mapping; /* Mapping to mixdown buffer index */
+ /* the actual, linearly interpolated amplitude with which the dsp sample should be mixed into the buf */
+ fluid_real_t current_amp;
+
+ /* the desired amplitude [...] mixed into the buf (directly set by e.g. rapidly changing PAN events) */
+ fluid_real_t target_amp;
+
+ /* Mapping to mixdown buffer index */
+ int mapping;
} bufs[FLUID_RVOICE_MAX_BUFS];
};
diff --git a/src/rvoice/fluid_rvoice_mixer.c b/src/rvoice/fluid_rvoice_mixer.c
index 64d4c2e1f..53a5cca8d 100644
--- a/src/rvoice/fluid_rvoice_mixer.c
+++ b/src/rvoice/fluid_rvoice_mixer.c
@@ -392,13 +392,17 @@ fluid_rvoice_buffers_mix(fluid_rvoice_buffers_t *buffers,
for(i = 0; i < bufcount; i++)
{
fluid_real_t *FLUID_RESTRICT buf = get_dest_buf(buffers, i, dest_bufs, dest_bufcount);
- fluid_real_t amp = buffers->bufs[i].amp;
+ fluid_real_t target_amp = buffers->bufs[i].target_amp;
+ fluid_real_t current_amp = buffers->bufs[i].current_amp;
+ fluid_real_t amp_incr;
- if(buf == NULL || amp == 0.0f)
+ if(buf == NULL || (current_amp == 0.0f && target_amp == 0.0f))
{
continue;
}
+ amp_incr = (target_amp - current_amp) / FLUID_BUFSIZE;
+
FLUID_ASSERT((uintptr_t)buf % FLUID_DEFAULT_ALIGNMENT == 0);
/* mixdown sample_count samples in the current buffer buf
@@ -406,13 +410,25 @@ fluid_rvoice_buffers_mix(fluid_rvoice_buffers_t *buffers,
#pragma omp simd aligned(dsp_buf,buf:FLUID_DEFAULT_ALIGNMENT)
for(dsp_i = 0; dsp_i < sample_count; dsp_i++)
{
+ fluid_real_t samp;
+ if(dsp_i < FLUID_BUFSIZE)
+ {
+ samp = (current_amp + amp_incr * dsp_i) * dsp_buf[start_block * FLUID_BUFSIZE + dsp_i];
+ }
+ else
+ {
+ samp = target_amp * dsp_buf[start_block * FLUID_BUFSIZE + dsp_i];
+ }
+
// Index by blocks (not by samples) to let the compiler know that we always start accessing
// buf and dsp_buf at the FLUID_BUFSIZE*sizeof(fluid_real_t) byte boundary and never somewhere
// in between.
// A good compiler should understand: Aha, so I don't need to add a peel loop when vectorizing
// this loop. Great.
- buf[start_block * FLUID_BUFSIZE + dsp_i] += amp * dsp_buf[start_block * FLUID_BUFSIZE + dsp_i];
+ buf[start_block * FLUID_BUFSIZE + dsp_i] += samp;
}
+
+ buffers->bufs[i].current_amp = target_amp;
}
}
-68
View File
@@ -1,68 +0,0 @@
From e5d1fac5253356178167e11aedf7652589041f0f Mon Sep 17 00:00:00 2001
From: derselbst <tom.mbrt@googlemail.com>
Date: Sat, 6 Feb 2021 16:23:03 +0100
Subject: [PATCH] Simplify control flow to allow auto-vectorization by compiler
---
src/rvoice/fluid_rvoice_mixer.c | 43 +++++++++++++++++++--------------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/src/rvoice/fluid_rvoice_mixer.c b/src/rvoice/fluid_rvoice_mixer.c
index 53a5cca8d..fd2cc956c 100644
--- a/src/rvoice/fluid_rvoice_mixer.c
+++ b/src/rvoice/fluid_rvoice_mixer.c
@@ -405,29 +405,36 @@ fluid_rvoice_buffers_mix(fluid_rvoice_buffers_t *buffers,
FLUID_ASSERT((uintptr_t)buf % FLUID_DEFAULT_ALIGNMENT == 0);
- /* mixdown sample_count samples in the current buffer buf
- Note, that this loop could be unrolled by FLUID_BUFSIZE elements */
+ /* Mixdown sample_count samples in the current buffer buf
+ *
+ * For the first FLUID_BUFSIZE samples, we linearly interpolate the buffers amplitude to
+ * avoid clicks/pops when rapidly changing the channels panning (issue 768).
+ *
+ * We could have squashed this into one single loop by using an if clause within the loop body.
+ * But it seems like having two separate loops is easier for compilers to understand, and therefore
+ * auto-vectorizing the loops.
+ */
#pragma omp simd aligned(dsp_buf,buf:FLUID_DEFAULT_ALIGNMENT)
- for(dsp_i = 0; dsp_i < sample_count; dsp_i++)
+ for(dsp_i = 0; dsp_i < FLUID_BUFSIZE; dsp_i++)
{
- fluid_real_t samp;
- if(dsp_i < FLUID_BUFSIZE)
- {
- samp = (current_amp + amp_incr * dsp_i) * dsp_buf[start_block * FLUID_BUFSIZE + dsp_i];
- }
- else
+ // We cannot simply increment current_amp by amp_incr during every iteration, as this would create a dependency and prevent vectorization.
+ buf[start_block * FLUID_BUFSIZE + dsp_i] += (current_amp + amp_incr * dsp_i) * dsp_buf[start_block * FLUID_BUFSIZE + dsp_i];
+ }
+
+ if(target_amp > 0)
+ {
+ /* Note, that this loop could be unrolled by FLUID_BUFSIZE elements */
+ #pragma omp simd aligned(dsp_buf,buf:FLUID_DEFAULT_ALIGNMENT)
+ for(dsp_i = FLUID_BUFSIZE; dsp_i < sample_count; dsp_i++)
{
- samp = target_amp * dsp_buf[start_block * FLUID_BUFSIZE + dsp_i];
+ // Index by blocks (not by samples) to let the compiler know that we always start accessing
+ // buf and dsp_buf at the FLUID_BUFSIZE*sizeof(fluid_real_t) byte boundary and never somewhere
+ // in between.
+ // A good compiler should understand: Aha, so I don't need to add a peel loop when vectorizing
+ // this loop. Great.
+ buf[start_block * FLUID_BUFSIZE + dsp_i] += target_amp * dsp_buf[start_block * FLUID_BUFSIZE + dsp_i];
}
-
- // Index by blocks (not by samples) to let the compiler know that we always start accessing
- // buf and dsp_buf at the FLUID_BUFSIZE*sizeof(fluid_real_t) byte boundary and never somewhere
- // in between.
- // A good compiler should understand: Aha, so I don't need to add a peel loop when vectorizing
- // this loop. Great.
- buf[start_block * FLUID_BUFSIZE + dsp_i] += samp;
}
-
buffers->bufs[i].current_amp = target_amp;
}
}
@@ -1,5 +1,5 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ccac10e2..00aaefa7 100644
index 595e6a4c..2b0ed9c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -442,6 +442,7 @@ if ( ASTYLE )
@@ -86,7 +86,7 @@ index 140fc3c5..5780367b 100644
/**
* Creates a new SoundFont loader.
diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c
index e2afd346..b0b2fee5 100644
index 1e0b29fb..cc3e0cc1 100644
--- a/src/synth/fluid_synth.c
+++ b/src/synth/fluid_synth.c
@@ -95,7 +95,9 @@ static int fluid_synth_render_blocks(fluid_synth_t *synth, int blockcount);