33#ifndef AAX_MISCUTILS_H
34#define AAX_MISCUTILS_H
40 #define DECLARE_ALIGNED(t,v,x) __declspec(align(x)) t v
42#elif defined (__GNUC__)
43 #define DECLARE_ALIGNED(t,v,x) t v __attribute__ ((aligned (x)))
45#elif defined (_TMS320C6X)
46 #define DECLARE_ALIGNED(t,v,x) t v
47 #warn "DECLARE_ALIGNED macro does not currently align data on TI"
49 #error "DigiError: Please port the DECLARE_ALIGNED macro to this platform"
59#define AAX_ALIGNMENT_HINT(a,b) std::_nassert(((int)(a) % b) == 0)
60#define AAX_WORD_ALIGNED_HINT(a) AAX_ALIGNMENT_HINT(a,4)
61#define AAX_DWORD_ALIGNED_HINT(a) AAX_ALIGNMENT_HINT(a,8)
63#define AAX_ALIGNMENT_HINT(a,b)
64#define AAX_WORD_ALIGNED_HINT(a)
65#define AAX_DWORD_ALIGNED_HINT(a)
74#define AAX_LO(x) (_itof(_lo((_amemd8_const(&x)))))
75#define AAX_HI(x) (_itof(_hi((_amemd8_const(&x)))))
76#define AAX_INT_LO(x) (_lo((_amemd8_const(&x))))
77#define AAX_INT_HI(x) (_hi((_amemd8_const(&x))))
80#define AAX_HI(x) *((const_cast<float*>(&x))+1)
81#define AAX_INT_LO(x) x
82#define AAX_INT_HI(x) *((const_cast<int32_t*>(reinterpret_cast<const int32_t*>(&x)))+1)
92inline GFLOAT
ClampToZero(GFLOAT iValue, GFLOAT iClampThreshold)
94 return (iValue < iClampThreshold && iValue > -iClampThreshold) ? 0.0 : iValue;
120 char* aCharPointer=
static_cast<char*
>(iPointer);
122 for(
int aIndex=0; aIndex<iNumBytes; aIndex++)
132 int* aDWPointer=
static_cast<int*
>(iPointer);
134 int numDWords=iNumBytes/
sizeof(int);
135 for(
int aIndex=0; aIndex<numDWords; aIndex++)
142template<
typename T,
int N>
void Fill( T *iArray,
const T* iVal )
145 for (
int i = 0; i != N; ++i)
147 *(iArray + i) = *iVal;
151template<
typename T,
int M,
int N >
inline void Fill( T *iArray,
const T* iVal )
153 for (
int i = 0; i != M; ++i )
155 Fill( iArray + i, iVal );
159template<
typename T,
int L,
int M,
int N >
inline void Fill( T *iArray,
const T* iVal )
161 for (
int i = 0; i != L; ++i )
163 Fill( iArray + i, iVal );
173#if defined(MAC_VERSION)
175 int* tempptr = (
reinterpret_cast<int*
>(&aVal))+cSignBitWord;
176 *tempptr &= 0x7fffffff;
180 return std::fabs(iVal);
190 int temp = (*(
reinterpret_cast<int*
>(&iVal)) & 0x7fffffff);
191 return *
reinterpret_cast<float*
>(&temp);
201inline T
AbsMax(
const T& iValue,
const T& iMax)
203 return std::fabs(iValue) < std::fabs(iMax) ? iMax : iValue;
207inline T
MinMax(
const T& iValue,
const T& iMin,
const T& iMax)
209 return iValue > iMax ? iMax : (iValue < iMin ? iMin : iValue);
213inline T
Max(
const T& iValue1,
const T& iValue2)
215 return iValue1 > iValue2 ? iValue1 : iValue2;
219inline T
Min(
const T& iValue1,
const T& iValue2)
221 return iValue1 < iValue2 ? iValue1 : iValue2;
227 return iValue < (T)(0.0) ? (T)(-1.0) : (T)(1.0);
231inline double PolyEval(
double x,
const double* coefs,
int numCoefs)
234 if(numCoefs < 1)
return 0.0;
236 double result = coefs[0];
237 for(
int i = 1; i < numCoefs; ++i)
239 result = result*x + coefs[i];
247 return std::pow(2.0f, (
float)(std::ceil(std::log(iValue)/std::log(2.0f))));
250inline void SinCosMix(
float aLinearMix,
float &aSinMix,
float &aCosMix)
252 aSinMix=
static_cast< float >( std::sin(aLinearMix*
cHalfPi) );
253 aCosMix=
static_cast< float >( std::cos(aLinearMix*
cHalfPi) );
Signal processing constants.
Signal processing utilities for denormal/subnormal floating point numbers.
Definition: AAX_EnvironmentUtilities.h:72
void ZeroMemoryDW(void *iPointer, int iNumBytes)
Definition: AAX_MiscUtils.h:130
void Fill(T *iArray, const T *iVal)
Definition: AAX_MiscUtils.h:142
void ZeroMemorySW(void *iPointer, int iNumBytes)
Definition: AAX_MiscUtils.h:118
void SinCosMix(float aLinearMix, float &aSinMix, float &aCosMix)
Definition: AAX_MiscUtils.h:250
T Min(const T &iValue1, const T &iValue2)
Definition: AAX_MiscUtils.h:219
const double cHalfPi
Definition: AAX_Constants.h:63
T Max(const T &iValue1, const T &iValue2)
Definition: AAX_MiscUtils.h:213
GFLOAT ClampToZero(GFLOAT iValue, GFLOAT iClampThreshold)
Definition: AAX_MiscUtils.h:92
float fabsf(float iVal)
Definition: AAX_MiscUtils.h:195
double PolyEval(double x, const double *coefs, int numCoefs)
Definition: AAX_MiscUtils.h:231
T AbsMax(const T &iValue, const T &iMax)
Definition: AAX_MiscUtils.h:201
double fabs(double iVal)
Definition: AAX_MiscUtils.h:170
double CeilLog2(double iValue)
Definition: AAX_MiscUtils.h:245
T Sign(const T &iValue)
Definition: AAX_MiscUtils.h:225
T MinMax(const T &iValue, const T &iMin, const T &iMax)
Definition: AAX_MiscUtils.h:207
const int cLittleEndian
Definition: AAX_Constants.h:58