23 #ifndef AAX_MISCUTILS_H
24 #define AAX_MISCUTILS_H
30 #define DECLARE_ALIGNED(t,v,x) __declspec(align(x)) t v
32 #elif defined (__GNUC__)
33 #define DECLARE_ALIGNED(t,v,x) t v __attribute__ ((aligned (x)))
35 #elif defined (_TMS320C6X)
36 #define DECLARE_ALIGNED(t,v,x) t v
37 #warn "DECLARE_ALIGNED macro does not currently align data on TI"
39 #error "DigiError: Please port the DECLARE_ALIGNED macro to this platform"
49 #define AAX_ALIGNMENT_HINT(a,b) std::_nassert(((int)(a) % b) == 0)
50 #define AAX_WORD_ALIGNED_HINT(a) AAX_ALIGNMENT_HINT(a,4)
51 #define AAX_DWORD_ALIGNED_HINT(a) AAX_ALIGNMENT_HINT(a,8)
53 #define AAX_ALIGNMENT_HINT(a,b)
54 #define AAX_WORD_ALIGNED_HINT(a)
55 #define AAX_DWORD_ALIGNED_HINT(a)
64 #define AAX_LO(x) (_itof(_lo((_amemd8_const(&x)))))
65 #define AAX_HI(x) (_itof(_hi((_amemd8_const(&x)))))
66 #define AAX_INT_LO(x) (_lo((_amemd8_const(&x))))
67 #define AAX_INT_HI(x) (_hi((_amemd8_const(&x))))
70 #define AAX_HI(x) *((const_cast<float*>(&x))+1)
71 #define AAX_INT_LO(x) x
72 #define AAX_INT_HI(x) *((const_cast<int32_t*>(reinterpret_cast<const int32_t*>(&x)))+1)
81 template<
class GFLOAT>
82 inline GFLOAT
ClampToZero(GFLOAT iValue, GFLOAT iClampThreshold)
84 return (iValue < iClampThreshold && iValue > -iClampThreshold) ? 0.0 : iValue;
110 char* aCharPointer=
static_cast<char*
>(iPointer);
112 for(
int aIndex=0; aIndex<iNumBytes; aIndex++)
122 int* aDWPointer=
static_cast<int*
>(iPointer);
124 int numDWords=iNumBytes/
sizeof(int);
125 for(
int aIndex=0; aIndex<numDWords; aIndex++)
132 template<
typename T,
int N>
void Fill( T *iArray,
const T* iVal )
135 for (
int i = 0; i != N; ++i)
137 *(iArray + i) = *iVal;
141 template<
typename T,
int M,
int N >
inline void Fill( T *iArray,
const T* iVal )
143 for (
int i = 0; i != M; ++i )
145 Fill( iArray + i, iVal );
149 template<
typename T,
int L,
int M,
int N >
inline void Fill( T *iArray,
const T* iVal )
151 for (
int i = 0; i != L; ++i )
153 Fill( iArray + i, iVal );
163 #if defined(MAC_VERSION)
165 int* tempptr = (
reinterpret_cast<int*
>(&aVal))+cSignBitWord;
166 *tempptr &= 0x7fffffff;
180 int temp = (*(
reinterpret_cast<int*
>(&iVal)) & 0x7fffffff);
181 return *
reinterpret_cast<float*
>(&temp);
191 inline T
AbsMax(
const T& iValue,
const T& iMax)
197 inline T
MinMax(
const T& iValue,
const T& iMin,
const T& iMax)
199 return iValue > iMax ? iMax : (iValue < iMin ? iMin : iValue);
203 inline T
Max(
const T& iValue1,
const T& iValue2)
205 return iValue1 > iValue2 ? iValue1 : iValue2;
209 inline T
Min(
const T& iValue1,
const T& iValue2)
211 return iValue1 < iValue2 ? iValue1 : iValue2;
217 return iValue < (T)(0.0) ? (T)(-1.0) : (T)(1.0);
221 inline double PolyEval(
double x,
const double* coefs,
int numCoefs)
224 if(numCoefs < 1)
return 0.0;
226 double result = coefs[0];
227 for(
int i = 1; i < numCoefs; ++i)
229 result = result*x + coefs[i];
237 return std::pow(2.0f, (
float)(std::ceil(std::log(iValue)/std::log(2.0f))));
240 inline void SinCosMix(
float aLinearMix,
float &aSinMix,
float &aCosMix)
242 aSinMix=
static_cast< float >( std::sin(aLinearMix*
cHalfPi) );
243 aCosMix=
static_cast< float >( std::cos(aLinearMix*
cHalfPi) );
Signal processing constants.
Signal processing utilities for denormal/subnormal floating point numbers.
Definition: AAX_Exception.h:42
void ZeroMemoryDW(void *iPointer, int iNumBytes)
Definition: AAX_MiscUtils.h:120
void Fill(T *iArray, const T *iVal)
Definition: AAX_MiscUtils.h:132
void SinCosMix(float aLinearMix, float &aSinMix, float &aCosMix)
Definition: AAX_MiscUtils.h:240
T Min(const T &iValue1, const T &iValue2)
Definition: AAX_MiscUtils.h:209
const double cHalfPi
Definition: AAX_Constants.h:53
T Max(const T &iValue1, const T &iValue2)
Definition: AAX_MiscUtils.h:203
GFLOAT ClampToZero(GFLOAT iValue, GFLOAT iClampThreshold)
Definition: AAX_MiscUtils.h:82
float fabsf(float iVal)
Definition: AAX_MiscUtils.h:185
double PolyEval(double x, const double *coefs, int numCoefs)
Definition: AAX_MiscUtils.h:221
T AbsMax(const T &iValue, const T &iMax)
Definition: AAX_MiscUtils.h:191
double fabs(double iVal)
Definition: AAX_MiscUtils.h:160
double CeilLog2(double iValue)
Definition: AAX_MiscUtils.h:235
T Sign(const T &iValue)
Definition: AAX_MiscUtils.h:215
T MinMax(const T &iValue, const T &iMin, const T &iMax)
Definition: AAX_MiscUtils.h:197
void ZeroMemory(void *iPointer, int iNumBytes)
Definition: AAX_MiscUtils.h:108
float fabs(float iVal)
Definition: AAX_MiscUtils.h:175
const int cLittleEndian
Definition: AAX_Constants.h:48