zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 30d1929a6ebdb15ed851ebb999c5d6356d9448e6
parent e28c988dfbd29ec6e3d388d377d5c9d1d11ec25a
Author: Hans Petter Selasky <hps@selasky.org>
Date:   Fri, 20 Nov 2020 12:53:20 +0100

Fix compile warning for clang.
Single precision floating point values only have a 24-bit mantissa.
Make sure constant fits into the mantissa.

Signed-off-by: Hans Petter Selasky <hps@selasky.org>

Diffstat:
Msrc/Misc/Util.h | 6+++---
Msrc/Synth/SynthNote.cpp | 2+-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/Misc/Util.h b/src/Misc/Util.h @@ -141,10 +141,10 @@ inline void sprng(prng_t p) /* * The random generator (0.0f..1.0f) */ -#ifndef INT32_MAX -#define INT32_MAX (2147483647) +#ifndef INT32_MAX_FLOAT +#define INT32_MAX_FLOAT 0x7fffff80 /* the float mantissa is only 24-bit */ #endif -#define RND (prng() / (INT32_MAX * 1.0f)) +#define RND (prng() / (INT32_MAX_FLOAT * 1.0f)) //Linear Interpolation float interpolate(const float *data, size_t len, float pos); diff --git a/src/Synth/SynthNote.cpp b/src/Synth/SynthNote.cpp @@ -193,7 +193,7 @@ float SynthNote::getFilterCutoffRelFreq(void) } float SynthNote::getRandomFloat() { - return (getRandomUint() / (INT32_MAX * 1.0f)); + return (getRandomUint() / (INT32_MAX_FLOAT * 1.0f)); } prng_t SynthNote::getRandomUint() {