Skip to content

Commit

Permalink
moved fastPow() to lmms_math.h
Browse files Browse the repository at this point in the history
  • Loading branch information
grejppi committed Apr 5, 2014
1 parent b0cdcc6 commit 6c33b4a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 37 deletions.
14 changes: 14 additions & 0 deletions include/lmms_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#ifndef _LMMS_MATH_H
#define _LMMS_MATH_H

#include <stdint.h>

#ifdef __INTEL_COMPILER

Expand Down Expand Up @@ -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<int32_t>( b * ( u.x[1] - 1072632447 ) + 1072632447 );
u.x[0] = 0;
return u.d;
}


#endif
2 changes: 1 addition & 1 deletion plugins/kicker/KickerOsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "DspEffectLibrary.h"
#include "Oscillator.h"

#include "fastpow.h"
#include "lmms_math.h"


template<class FX = DspEffectLibrary::StereoBypass>
Expand Down
22 changes: 0 additions & 22 deletions plugins/kicker/fastpow.h

This file was deleted.

15 changes: 1 addition & 14 deletions plugins/monstro/Monstro.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) \
Expand Down Expand Up @@ -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<int32_t>( b * ( u.x[1] - 1072632447 ) + 1072632447 );
u.x[0] = 0;
return u.d;
}


class MonstroSynth
{
Expand Down

0 comments on commit 6c33b4a

Please sign in to comment.