made oscillator-phase always being positive which allows further optimizations of fraction()-method
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1431 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -31,21 +31,67 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
// Equivalent to _x - floorf( _x )
|
||||
static inline float fraction( const float _x )
|
||||
static inline float absFraction( const float _x )
|
||||
{
|
||||
return( _x - ( _x >= 0.0f ? floorf( _x ) : floorf( _x ) - 1 ) );
|
||||
}
|
||||
|
||||
static inline float fraction( const float _x )
|
||||
{
|
||||
return( _x - floorf( _x ) );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Equivalent to _x - floorf( _x )
|
||||
static inline float fraction( const float _x )
|
||||
static inline float absFraction( const float _x )
|
||||
{
|
||||
return( _x - ( _x >= 0.0f ? static_cast<int>( _x ) :
|
||||
static_cast<int>( _x ) - 1 ) );
|
||||
}
|
||||
|
||||
static inline float fraction( const float _x )
|
||||
{
|
||||
return( _x - static_cast<int>( _x ) );
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// SSE3-version
|
||||
static inline float absFraction( float _x )
|
||||
{
|
||||
unsigned int tmp;
|
||||
asm(
|
||||
"fld %%st\n\t"
|
||||
"fisttp %1\n\t"
|
||||
"fild %1\n\t"
|
||||
"ftst\n\t"
|
||||
"sahf\n\t"
|
||||
"jae 1f\n\t"
|
||||
"fld1\n\t"
|
||||
"fsubrp %%st, %%st(1)\n\t"
|
||||
"1:\n\t"
|
||||
"fsubrp %%st, %%st(1)"
|
||||
: "+t"( _x ), "=m"( tmp )
|
||||
:
|
||||
: "st(1)", "cc" );
|
||||
return( _x );
|
||||
}
|
||||
|
||||
static inline float absFraction( float _x )
|
||||
{
|
||||
unsigned int tmp;
|
||||
asm(
|
||||
"fld %%st\n\t"
|
||||
"fisttp %1\n\t"
|
||||
"fild %1\n\t"
|
||||
"fsubrp %%st, %%st(1)"
|
||||
: "+t"( _x ), "=m"( tmp )
|
||||
:
|
||||
: "st(1)" );
|
||||
return( _x );
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user