From 6c33b4af80bfa8ff0069d3bde24682823046fc0b Mon Sep 17 00:00:00 2001 From: Hannu Haahti Date: Sat, 5 Apr 2014 03:32:54 +0300 Subject: [PATCH] moved fastPow() to lmms_math.h --- include/lmms_math.h | 14 ++++++++++++++ plugins/kicker/KickerOsc.h | 2 +- plugins/kicker/fastpow.h | 22 ---------------------- plugins/monstro/Monstro.h | 15 +-------------- 4 files changed, 16 insertions(+), 37 deletions(-) delete mode 100644 plugins/kicker/fastpow.h diff --git a/include/lmms_math.h b/include/lmms_math.h index 57454ac57..b82e589a7 100644 --- a/include/lmms_math.h +++ b/include/lmms_math.h @@ -26,6 +26,7 @@ #ifndef _LMMS_MATH_H #define _LMMS_MATH_H +#include #ifdef __INTEL_COMPILER @@ -106,5 +107,18 @@ static inline int fast_rand() +// source: http://martin.ankerl.com/2007/10/04/optimized-pow-approximation-for-java-and-c-c/ +static inline double fastPow( double a, double b ) +{ + union + { + double d; + int32_t x[2]; + } u = { a }; + u.x[1] = static_cast( b * ( u.x[1] - 1072632447 ) + 1072632447 ); + u.x[0] = 0; + return u.d; +} + #endif diff --git a/plugins/kicker/KickerOsc.h b/plugins/kicker/KickerOsc.h index edcdcf5e5..6fdabdb1d 100644 --- a/plugins/kicker/KickerOsc.h +++ b/plugins/kicker/KickerOsc.h @@ -29,7 +29,7 @@ #include "DspEffectLibrary.h" #include "Oscillator.h" -#include "fastpow.h" +#include "lmms_math.h" template diff --git a/plugins/kicker/fastpow.h b/plugins/kicker/fastpow.h deleted file mode 100644 index 48fd83c03..000000000 --- a/plugins/kicker/fastpow.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef FASTPOW_H -#define FASTPOW_H - -#include - -/* - * source: - * http://martin.ankerl.com/2007/10/04/optimized-pow-approximation-for-java-and-c-c/ - */ - -double fastPow(double a, double b) { - union { - double d; - int32_t x[2]; - } u = { a }; - u.x[1] = (int32_t)(b * (u.x[1] - 1072632447) + 1072632447); - u.x[0] = 0; - return u.d; -} - -#endif diff --git a/plugins/monstro/Monstro.h b/plugins/monstro/Monstro.h index b86525ad0..79acbcced 100644 --- a/plugins/monstro/Monstro.h +++ b/plugins/monstro/Monstro.h @@ -36,7 +36,7 @@ #include "pixmap_button.h" #include "combobox.h" #include "Oscillator.h" -// #include "fastpow.h" // once grejppi's fastpow gets merged +#include "lmms_math.h" #define makeknob( name, x, y, hint, unit, oname ) \ @@ -153,19 +153,6 @@ const float MAX_FREQ = 48000.0f; class MonstroInstrument; class MonstroView; -// use grejppi's once it's merged -inline double fastPow( double a, double b ) -{ - union - { - double d; - int32_t x[2]; - } u = { a }; - u.x[1] = static_cast( b * ( u.x[1] - 1072632447 ) + 1072632447 ); - u.x[0] = 0; - return u.d; -} - class MonstroSynth {