From ce7d0133b95729e76efa823169ddaa4a46a7b1e8 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Wed, 23 May 2018 15:45:56 +0200 Subject: [PATCH] Small FPU optimisations. --- EngineMkI.cpp | 4 ++-- dx7note.cpp | 10 ++++++---- sin.cpp | 4 ++-- synth.h | 4 ++++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/EngineMkI.cpp b/EngineMkI.cpp index 2a88c7f..efe9254 100644 --- a/EngineMkI.cpp +++ b/EngineMkI.cpp @@ -38,7 +38,7 @@ #if _MSC_VER < 1800 FRAC_NUM log2(FRAC_NUM n) { //return log(n) / log(2.0); - return logf(n) / logf(2.0); + return LOG_FUNC(n) / LOG_FUNC(2.0); } FRAC_NUM round(FRAC_NUM n) { return n < 0.0 ? ceil(n - 0.5) : floor(n + 0.5); @@ -83,7 +83,7 @@ EngineMkI::EngineMkI() { for(int i=0;i> 24); // TODO: mehhh.. this needs some real tuning. - uint32_t pt = exp(((float)sensamp) / 262144 * 0.07 + 12.2); + //uint32_t pt = exp(((float)sensamp) / 262144 * 0.07 + 12.2); + uint32_t pt = EXP_FUNC(((float)sensamp) / 262144 * 0.07 + 12.2); uint32_t ldiff = (uint32_t)(((uint64_t)level) * (((uint64_t)pt << 4)) >> 28); level -= ldiff; } diff --git a/sin.cpp b/sin.cpp index 955c3bb..1949cd5 100644 --- a/sin.cpp +++ b/sin.cpp @@ -31,9 +31,9 @@ int32_t sintab[SIN_N_SAMPLES + 1]; void Sin::init() { FRAC_NUM dphase = 2 * M_PI / SIN_N_SAMPLES; //int32_t c = (int32_t)floor(cos(dphase) * (1 << 30) + 0.5); - int32_t c = (int32_t)floor(cosf(dphase) * (1 << 30) + 0.5); + int32_t c = (int32_t)floor(COS_FUNC(dphase) * (1 << 30) + 0.5); //int32_t s = (int32_t)floor(sin(dphase) * (1 << 30) + 0.5); - int32_t s = (int32_t)floor(sinf(dphase) * (1 << 30) + 0.5); + int32_t s = (int32_t)floor(SIN_FUNC(dphase) * (1 << 30) + 0.5); int32_t u = 1 << 30; int32_t v = 0; for (int i = 0; i < SIN_N_SAMPLES / 2; i++) { diff --git a/synth.h b/synth.h index 6080590..dc07e3b 100644 --- a/synth.h +++ b/synth.h @@ -63,5 +63,9 @@ inline static T max(const T& a, const T& b) { #define QER(n,b) ( ((float)n)/(1<