summaryrefslogtreecommitdiffstats
path: root/lib/reverb/basics.h
diff options
context:
space:
mode:
authorTimothy Rae <perceptualchaos2@gmail.com>2017-01-11 13:14:58 +0900
committerTimothy Rae <perceptualchaos2@gmail.com>2017-01-11 13:14:58 +0900
commit84a5954e31225ec77d6e78a2ecfd9aea611e191f (patch)
tree787c62fd083f65bd23e0345381ba3d807324c34c /lib/reverb/basics.h
parent836db6a1494ae4e3cf3aea7537580a0c3d87e585 (diff)
Fix the reverb effect
The previous implementation of the reverb effect was suffering from serious artifacts in terms of feedback / distortion that the original LADSPA plugin doesn't suffer from: https://bugs.launchpad.net/mixxx/+bug/1647568 I updated the code base to use the latest version (0.9.24) from the original author (http://quitte.de/dsp/caps.html), and in doing this I disabled the unused code with preprocessor directives instead of deleting it, in order to make it easier to update in the future. Next I tried to track down where the bug was. It turns out that the `SampleUtil::linearCrossfadeBuffers()` call was causing all the feedback problems, and it seems to be safe to remove this. In the future we should use ramping on the parameters. This commit also adds the missing two controls for damping and blend, and remaps the meta knob from bandwidth to blend, which fixes the following bug: https://bugs.launchpad.net/mixxx/+bug/1647775 Note that the meaning of "blend" has changed compared to the original source code, as we use it as a "send amount" instead of wet/dry. This has the advantage that the reverb tail is not suddenly cut off when the blend knob is turned down to zero. In the PR (#1113) it was discussed that in the future we should probably implement wet/dry and send functions at the system level rather than forcing individual effects to implement it.
Diffstat (limited to 'lib/reverb/basics.h')
-rw-r--r--lib/reverb/basics.h54
1 files changed, 11 insertions, 43 deletions
diff --git a/lib/reverb/basics.h b/lib/reverb/basics.h
index 36275ae796..8fe92b68fa 100644
--- a/lib/reverb/basics.h
+++ b/lib/reverb/basics.h
@@ -29,8 +29,8 @@
02111-1307, USA or point your web browser to http://www.gnu.org.
*/
-#ifndef _BASICS_H_
-#define _BASICS_H_
+#ifndef BASICS_H
+#define BASICS_H
// NOTE(rryan): 3/2014 Added for MSVC support. (missing M_PI)
#define _USE_MATH_DEFINES
@@ -59,9 +59,9 @@ typedef quint32 uint32;
typedef qint64 int64;
typedef quint64 uint64;
-#define MIN_GAIN .000001 /* -120 dB */
+#define MIN_GAIN 1e-6 /* -120 dB */
/* smallest non-denormal 32 bit IEEE float is 1.18e-38 */
-#define NOISE_FLOOR .00000000000005 /* -266 dB */
+#define NOISE_FLOOR 1e-20 /* -400 dB */
/* //////////////////////////////////////////////////////////////////////// */
@@ -71,29 +71,9 @@ typedef unsigned long ulong;
/* prototype that takes a sample and yields a sample */
typedef CSAMPLE (*clip_func_t) (CSAMPLE);
-/* flavours for sample store functions run() and run_adding() */
-typedef void (*yield_func_t) (CSAMPLE *, uint, CSAMPLE, CSAMPLE);
-
-inline void
-adding_func (CSAMPLE * s, uint i, CSAMPLE x, CSAMPLE gain)
-{
- s[i] += gain * x;
-}
-
#ifndef max
-
-template <class X, class Y>
-X min (X x, Y y)
-{
- return x < y ? x : (X) y;
-}
-
-template <class X, class Y>
-X max (X x, Y y)
-{
- return x > y ? x : (X) y;
-}
-
+template <class X, class Y> X min (X x, Y y) { return x < (X)y ? x : (X)y; }
+template <class X, class Y> X max (X x, Y y) { return x > (X)y ? x : (X)y; }
#endif /* ! max */
template <class T>
@@ -104,11 +84,8 @@ T clamp (T value, T lower, T upper)
return value;
}
-static inline float
-frandom()
-{
- return (float) rand() / (float) RAND_MAX;
-}
+// (timrae) change random() to rand() for MSVC support
+static inline float frandom() { return (float) rand() / (float) RAND_MAX; }
/* NB: also true if 0 */
inline bool
@@ -144,18 +121,9 @@ next_power_of_2 (uint n)
return ++n;
}
-inline double
-db2lin (double db)
-{
- return pow(10, db*.05);
-}
-
-inline double
-lin2db (double lin)
-{
- return 20*log10(lin);
-}
+inline double db2lin (double db) { return pow(10, .05*db); }
+inline double lin2db (double lin) { return 20*log10(lin); }
/* //////////////////////////////////////////////////////////////////////// */
-#endif /* _BASICS_H_ */
+#endif /* BASICS_H */