[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[fluid-dev] [PATCH] Effect level clip
From: |
David Hilvert |
Subject: |
[fluid-dev] [PATCH] Effect level clip |
Date: |
Tue, 31 Jul 2007 09:53:27 -0500 |
Overview
The following patch moves effect level adjustments prior to the send clip, and
reduces the chorus effect linearly with the number of voices. These changes
seem to make output (volume) levels more uniform; in particular, the phenomenon
of certain instruments with high choral component being several times louder
than those with low choral component seems to be mitigated across a variety of
synthesizer parameter settings.
Notes
- The magnitude of the choral effect for large N is reduced by this patch; some
reduction is also present at smaller N.
- Effect level defaults have been adjusted so that qsynth's center is neutral.
Better might be to balance the scale around 0, with 0 neutral.
- The patch is against version 1.0.7a.
Patch follows.
diff -ubr fluidsynth-1.0.7/include/fluidsynth/synth.h
fluidsynth-modified/include/fluidsynth/synth.h
--- fluidsynth-1.0.7/include/fluidsynth/synth.h 2005-06-12 01:19:37.000000000
+0000
+++ fluidsynth-modified/include/fluidsynth/synth.h 2007-07-30
22:12:06.000000000 +0000
@@ -291,7 +291,7 @@
#define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f
#define FLUID_REVERB_DEFAULT_DAMP 0.0f
#define FLUID_REVERB_DEFAULT_WIDTH 0.5f
-#define FLUID_REVERB_DEFAULT_LEVEL 0.9f
+#define FLUID_REVERB_DEFAULT_LEVEL 0.5f
@@ -325,7 +325,7 @@
/* Those are the default settings for the chorus. */
#define FLUID_CHORUS_DEFAULT_N 3
-#define FLUID_CHORUS_DEFAULT_LEVEL 2.0f
+#define FLUID_CHORUS_DEFAULT_LEVEL 6.25f
#define FLUID_CHORUS_DEFAULT_SPEED 0.3f
#define FLUID_CHORUS_DEFAULT_DEPTH 8.0f
#define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE
diff -ubr fluidsynth-1.0.7/src/fluid_chorus.c
fluidsynth-modified/src/fluid_chorus.c
--- fluidsynth-1.0.7/src/fluid_chorus.c 2003-03-11 16:57:10.000000000 +0000
+++ fluidsynth-modified/src/fluid_chorus.c 2007-07-30 23:07:08.000000000
+0000
@@ -477,7 +477,8 @@
chorus->phase[i] %= (chorus->modulation_period_samples);
} /* foreach chorus block */
- d_out *= chorus->level;
+ if (chorus->number_blocks)
+ d_out /= chorus->number_blocks;
/* Add the chorus sum d_out to output */
left_out[sample_index] += d_out;
@@ -544,7 +545,8 @@
chorus->phase[i] %= (chorus->modulation_period_samples);
} /* foreach chorus block */
- d_out *= chorus->level;
+ if (chorus->number_blocks)
+ d_out /= chorus->number_blocks;
/* Add the chorus sum d_out to output */
left_out[sample_index] = d_out;
diff -ubr fluidsynth-1.0.7/src/fluid_rev.c fluidsynth-modified/src/fluid_rev.c
--- fluidsynth-1.0.7/src/fluid_rev.c 2004-03-29 10:05:18.000000000 +0000
+++ fluidsynth-modified/src/fluid_rev.c 2007-07-30 22:04:24.000000000 +0000
@@ -272,6 +272,7 @@
fluid_real_t roomsize;
fluid_real_t damp;
fluid_real_t wet, wet1, wet2;
+ fluid_real_t level;
fluid_real_t width;
fluid_real_t gain;
/*
@@ -534,15 +535,13 @@
void
fluid_revmodel_setlevel(fluid_revmodel_t* rev, fluid_real_t value)
{
-/* fluid_clip(value, 0.0f, 1.0f); */
-/* rev->wet = value * scalewet; */
-/* fluid_revmodel_update(rev); */
+ rev->level = value;
}
fluid_real_t
fluid_revmodel_getlevel(fluid_revmodel_t* rev)
{
- return rev->wet / scalewet;
+ return rev->level;
}
void
diff -ubr fluidsynth-1.0.7/src/fluid_synth.c
fluidsynth-modified/src/fluid_synth.c
--- fluidsynth-1.0.7/src/fluid_synth.c 2006-02-19 07:19:07.000000000 +0000
+++ fluidsynth-modified/src/fluid_synth.c 2007-07-30 22:06:44.000000000
+0000
@@ -1762,6 +1762,8 @@
fluid_real_t* chorus_buf;
int byte_size = FLUID_BUFSIZE * sizeof(fluid_real_t);
double prof_ref = fluid_profile_ref();
+ fluid_real_t chorus_level = fluid_chorus_get_level(synth->chorus);
+ fluid_real_t reverb_level = fluid_revmodel_getlevel(synth->reverb);
/* fluid_mutex_lock(synth->busy); /\* Here comes the audio thread. Lock the
synth. *\/ */
@@ -1820,11 +1822,20 @@
left_buf = synth->left_buf[auchan];
right_buf = synth->right_buf[auchan];
+ fluid_voice_set_param(voice, GEN_CHORUSSEND,
+ 1000.0
+ * (chorus_level - FLUID_CHORUS_DEFAULT_LEVEL)
+ / FLUID_CHORUS_DEFAULT_LEVEL, 1 /* ? */);
+ fluid_voice_set_param(voice, GEN_REVERBSEND,
+ 1000.0
+ * (reverb_level - FLUID_REVERB_DEFAULT_LEVEL)
+ / FLUID_REVERB_DEFAULT_LEVEL, 1 /* ? */);
fluid_voice_write(voice, left_buf, right_buf, reverb_buf, chorus_buf);
fluid_profile(FLUID_PROF_ONE_BLOCK_VOICE, prof_ref_voice);
}
}
+
fluid_check_fpe("Synthesis processes");
fluid_profile(FLUID_PROF_ONE_BLOCK_VOICES, prof_ref);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [fluid-dev] [PATCH] Effect level clip,
David Hilvert <=