20#ifndef AAX_MISCUTILS_H
21#define AAX_MISCUTILS_H
27 #define DECLARE_ALIGNED(t,v,x) __declspec(align(x)) t v
29#elif defined (__GNUC__)
30 #define DECLARE_ALIGNED(t,v,x) t v __attribute__ ((aligned (x)))
32#elif defined (_TMS320C6X)
33 #define DECLARE_ALIGNED(t,v,x) t v
34 #warn "DECLARE_ALIGNED macro does not currently align data on TI"
36 #error "DigiError: Please port the DECLARE_ALIGNED macro to this platform"
46#define AAX_ALIGNMENT_HINT(a,b) std::_nassert(((int)(a) % b) == 0)
47#define AAX_WORD_ALIGNED_HINT(a) AAX_ALIGNMENT_HINT(a,4)
48#define AAX_DWORD_ALIGNED_HINT(a) AAX_ALIGNMENT_HINT(a,8)
50#define AAX_ALIGNMENT_HINT(a,b)
51#define AAX_WORD_ALIGNED_HINT(a)
52#define AAX_DWORD_ALIGNED_HINT(a)
61#define AAX_LO(x) (_itof(_lo((_amemd8_const(&x)))))
62#define AAX_HI(x) (_itof(_hi((_amemd8_const(&x)))))
63#define AAX_INT_LO(x) (_lo((_amemd8_const(&x))))
64#define AAX_INT_HI(x) (_hi((_amemd8_const(&x))))
67#define AAX_HI(x) *((const_cast<float*>(&x))+1)
68#define AAX_INT_LO(x) x
69#define AAX_INT_HI(x) *((const_cast<int32_t*>(reinterpret_cast<const int32_t*>(&x)))+1)
79inline GFLOAT
ClampToZero(GFLOAT iValue, GFLOAT iClampThreshold)
81 return (iValue < iClampThreshold && iValue > -iClampThreshold) ? 0.0 : iValue;
107 char* aCharPointer=
static_cast<char*
>(iPointer);
109 for(
int aIndex=0; aIndex<iNumBytes; aIndex++)
119 int* aDWPointer=
static_cast<int*
>(iPointer);
121 int numDWords=iNumBytes/
sizeof(int);
122 for(
int aIndex=0; aIndex<numDWords; aIndex++)
129template<
typename T,
int N>
void Fill( T *iArray,
const T* iVal )
132 for (
int i = 0; i != N; ++i)
134 *(iArray + i) = *iVal;
138template<
typename T,
int M,
int N >
inline void Fill( T *iArray,
const T* iVal )
140 for (
int i = 0; i != M; ++i )
142 Fill( iArray + i, iVal );
146template<
typename T,
int L,
int M,
int N >
inline void Fill( T *iArray,
const T* iVal )
148 for (
int i = 0; i != L; ++i )
150 Fill( iArray + i, iVal );
160#if defined(MAC_VERSION)
162 int* tempptr = (
reinterpret_cast<int*
>(&aVal))+cSignBitWord;
163 *tempptr &= 0x7fffffff;
167 return std::fabs(iVal);
177 int temp = (*(
reinterpret_cast<int*
>(&iVal)) & 0x7fffffff);
178 return *
reinterpret_cast<float*
>(&temp);
188inline T
AbsMax(
const T& iValue,
const T& iMax)
190 return std::fabs(iValue) < std::fabs(iMax) ? iMax : iValue;
194inline T
MinMax(
const T& iValue,
const T& iMin,
const T& iMax)
196 return iValue > iMax ? iMax : (iValue < iMin ? iMin : iValue);
200inline T
Max(
const T& iValue1,
const T& iValue2)
202 return iValue1 > iValue2 ? iValue1 : iValue2;
206inline T
Min(
const T& iValue1,
const T& iValue2)
208 return iValue1 < iValue2 ? iValue1 : iValue2;
214 return iValue < (T)(0.0) ? (T)(-1.0) : (T)(1.0);
218inline double PolyEval(
double x,
const double* coefs,
int numCoefs)
221 if(numCoefs < 1)
return 0.0;
223 double result = coefs[0];
224 for(
int i = 1; i < numCoefs; ++i)
226 result = result*x + coefs[i];
234 return std::pow(2.0f, (
float)(std::ceil(std::log(iValue)/std::log(2.0f))));
237inline void SinCosMix(
float aLinearMix,
float &aSinMix,
float &aCosMix)
239 aSinMix=
static_cast< float >( std::sin(aLinearMix*
cHalfPi) );
240 aCosMix=
static_cast< float >( std::cos(aLinearMix*
cHalfPi) );
Signal processing constants.
Signal processing utilities for denormal/subnormal floating point numbers.
Definition: AAX_EnvironmentUtilities.h:59
void ZeroMemoryDW(void *iPointer, int iNumBytes)
Definition: AAX_MiscUtils.h:117
void Fill(T *iArray, const T *iVal)
Definition: AAX_MiscUtils.h:129
void ZeroMemorySW(void *iPointer, int iNumBytes)
Definition: AAX_MiscUtils.h:105
void SinCosMix(float aLinearMix, float &aSinMix, float &aCosMix)
Definition: AAX_MiscUtils.h:237
T Min(const T &iValue1, const T &iValue2)
Definition: AAX_MiscUtils.h:206
const double cHalfPi
Definition: AAX_Constants.h:50
T Max(const T &iValue1, const T &iValue2)
Definition: AAX_MiscUtils.h:200
GFLOAT ClampToZero(GFLOAT iValue, GFLOAT iClampThreshold)
Definition: AAX_MiscUtils.h:79
float fabsf(float iVal)
Definition: AAX_MiscUtils.h:182
double PolyEval(double x, const double *coefs, int numCoefs)
Definition: AAX_MiscUtils.h:218
T AbsMax(const T &iValue, const T &iMax)
Definition: AAX_MiscUtils.h:188
double fabs(double iVal)
Definition: AAX_MiscUtils.h:157
double CeilLog2(double iValue)
Definition: AAX_MiscUtils.h:232
T Sign(const T &iValue)
Definition: AAX_MiscUtils.h:212
T MinMax(const T &iValue, const T &iMin, const T &iMax)
Definition: AAX_MiscUtils.h:194
const int cLittleEndian
Definition: AAX_Constants.h:45