\hypertarget{a00671_source}{}\doxysection{AAX\+\_\+\+Common\+Conversions.\+h}
\label{a00671_source}\index{AAX\_CommonConversions.h@{AAX\_CommonConversions.h}}
\mbox{\hyperlink{a00671}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ \ Copyright\ 2014-\/2015,\ 2023-\/2024\ Avid\ Technology,\ Inc.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *\ \ All\ rights\ reserved.}}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ \ This\ file\ is\ part\ of\ the\ Avid\ AAX\ SDK.}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *\ \ The\ AAX\ SDK\ is\ subject\ to\ commercial\ or\ open-\/source\ licensing.}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00011\ \textcolor{comment}{\ *\ \ By\ using\ the\ AAX\ SDK,\ you\ agree\ to\ the\ terms\ of\ both\ the\ Avid\ AAX\ SDK\ License}}
\DoxyCodeLine{00012\ \textcolor{comment}{\ *\ \ Agreement\ and\ Avid\ Privacy\ Policy.}}
\DoxyCodeLine{00013\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00014\ \textcolor{comment}{\ *\ \ AAX\ SDK\ License:\ https://developer.avid.com/aax}}
\DoxyCodeLine{00015\ \textcolor{comment}{\ *\ \ Privacy\ Policy:\ https://www.avid.com/legal/privacy-\/policy-\/statement}}
\DoxyCodeLine{00016\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00017\ \textcolor{comment}{\ *\ \ Or:\ You\ may\ also\ use\ this\ code\ under\ the\ terms\ of\ the\ GPL\ v3\ (see}}
\DoxyCodeLine{00018\ \textcolor{comment}{\ *\ \ www.gnu.org/licenses).}}
\DoxyCodeLine{00019\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00020\ \textcolor{comment}{\ *\ \ THE\ AAX\ SDK\ IS\ PROVIDED\ "{}AS\ IS"{}\ WITHOUT\ ANY\ WARRANTY,\ AND\ ALL\ WARRANTIES,\ WHETHER}}
\DoxyCodeLine{00021\ \textcolor{comment}{\ *\ \ EXPRESSED\ OR\ IMPLIED,\ INCLUDING\ MERCHANTABILITY\ AND\ FITNESS\ FOR\ PURPOSE,\ ARE}}
\DoxyCodeLine{00022\ \textcolor{comment}{\ *\ \ DISCLAIMED.}}
\DoxyCodeLine{00023\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00024\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00025\ }
\DoxyCodeLine{00030\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00031\ }
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00033\ \textcolor{preprocessor}{\#ifndef\ AAX\_COMMONCONVERIONS\_H}}
\DoxyCodeLine{00034\ \textcolor{preprocessor}{\#define\ AAX\_COMMONCONVERIONS\_H}}
\DoxyCodeLine{00035\ }
\DoxyCodeLine{00036\ \textcolor{preprocessor}{\#include\ <math.h>}}
\DoxyCodeLine{00037\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00542}{AAX.h}}"{}}}
\DoxyCodeLine{00038\ }
\DoxyCodeLine{00039\ }
\DoxyCodeLine{00040\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00671_a6758dcc7fe73efcefb9980ff895c36d0}{k32BitPosMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x7FFFFFFF;}
\DoxyCodeLine{00041\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00671_a19c3de953254f182959cb74c9f6ed055}{k32BitAbsMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x80000000;}
\DoxyCodeLine{00042\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00671_a4623748ef4a22daea8cbbf7557ecb60e}{k32BitNegMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x80000000;}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00044\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00671_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x007FFFFF;\ \ \ \textcolor{comment}{//\ Positive\ Max\ Value\ }}
\DoxyCodeLine{00045\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00671_ad6054f9b9b26d0b3ee01a6ef097afaea}{k56kFracAbsMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x00800000;\ \ \ \textcolor{comment}{//\ Absolute\ Max\ Value.\ Essentially\ negative\ one\ without\ the\ sign\ extension.}}
\DoxyCodeLine{00046\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00671_a485384e2f324b1666ad9d8600c442d61}{k56kFracHalf}}\ \ \ \ \ \ \ \ \ \ =\ 0x00400000;}
\DoxyCodeLine{00047\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00671_affbe56efc7321622e3d4c1e2ef60cb28}{k56kFracNegOne}}\ \ \ \ \ \ \ \ \ \ =\ 0xFF800000;\ \ \ \textcolor{comment}{//Note\ sign\ extension!!!}}
\DoxyCodeLine{00048\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00671_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}}\ \ \ \ \ \ \ \ \ \ =\ \mbox{\hyperlink{a00671_affbe56efc7321622e3d4c1e2ef60cb28}{k56kFracNegOne}};\ \textcolor{comment}{//Note\ sign\ extension!!!}}
\DoxyCodeLine{00049\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00671_aeb01246d63cd5b5d1b6c6eb5bcd08b8b}{k56kFracZero}}\ \ \ \ \ \ \ \ \ \ =\ 0x00000000;}
\DoxyCodeLine{00050\ }
\DoxyCodeLine{00051\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00671_a5ad86b72eda6b0e72864ec774adad1cf}{kOneOver56kFracAbsMax}}\ =\ 1.0/double(\mbox{\hyperlink{a00671_ad6054f9b9b26d0b3ee01a6ef097afaea}{k56kFracAbsMax}});}
\DoxyCodeLine{00052\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00671_abc7ad084f4b51c70feeac700ab05f7a5}{k56kFloatPosMax}}\ \ \ \ \ =\ double(\mbox{\hyperlink{a00671_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}})/double(\mbox{\hyperlink{a00671_ad6054f9b9b26d0b3ee01a6ef097afaea}{k56kFracAbsMax}});\ \ \ \ \ \ \ \ \textcolor{comment}{//56k\ Max\ value\ represented\ in\ floating\ point\ format.}}
\DoxyCodeLine{00053\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00671_ae1518eaa8f13def92b4c9daeedbbe002}{k56kFloatNegMax}}\ \ \ \ \ =\ -\/1.0;\ \ \ \ \ \textcolor{comment}{//56k\ Min\ value\ represented\ in\ floating\ point\ format.}}
\DoxyCodeLine{00054\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00671_a2381bc3bc0a4c5e07bf67baf7d440137}{kNeg144DB}}\ \ \ \ \ \ \ \ \ \ \ \ \ =\ -\/144.0;}
\DoxyCodeLine{00055\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00671_a1baf8195909ae1265cbb609e6702d2b4}{kNeg144Gain}}\ \ \ \ \ \ \ \ \ =\ 6.3095734448019324943436013662234e-\/8;\ \textcolor{comment}{//pow(10.0,\ kNeg144DB\ /\ 20.0);}}
\DoxyCodeLine{00056\ }
\DoxyCodeLine{00062\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \ \ \mbox{\hyperlink{a00671_a76f29f12e35c093e5c198b8d0e27b6f9}{GainToDB}}(\textcolor{keywordtype}{double}\ aGain)}
\DoxyCodeLine{00063\ \{}
\DoxyCodeLine{00064\ \ \ \ \ \textcolor{keywordflow}{if}\ (aGain\ ==\ 0.0)}
\DoxyCodeLine{00065\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00671_a2381bc3bc0a4c5e07bf67baf7d440137}{kNeg144DB}};}
\DoxyCodeLine{00066\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00067\ \ \ \ \ \{}
\DoxyCodeLine{00068\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{double}\ \ dB;}
\DoxyCodeLine{00069\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ dB\ =\ log10(aGain)\ *\ 20.0;}
\DoxyCodeLine{00071\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00072\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (dB\ <\ \mbox{\hyperlink{a00671_a2381bc3bc0a4c5e07bf67baf7d440137}{kNeg144DB}})}
\DoxyCodeLine{00073\ \ \ \ \ \ \ \ \ \ \ \ \ dB\ =\ \mbox{\hyperlink{a00671_a2381bc3bc0a4c5e07bf67baf7d440137}{kNeg144DB}};}
\DoxyCodeLine{00074\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ (dB);\ \ \ \ \ \ \ \ \textcolor{comment}{//\ convert\ factor\ to\ dB}}
\DoxyCodeLine{00075\ \ \ \ \ \}}
\DoxyCodeLine{00076\ \}}
\DoxyCodeLine{00077\ }
\DoxyCodeLine{00083\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00671_a596d5ea393d43f6f798a838aefe3cecd}{DBToGain}}(\textcolor{keywordtype}{double}\ dB)}
\DoxyCodeLine{00084\ \{}
\DoxyCodeLine{00085\ \ \ \ \ \textcolor{keywordflow}{return}\ pow(10.0,\ dB\ /\ 20.0);}
\DoxyCodeLine{00086\ \}}
\DoxyCodeLine{00087\ }
\DoxyCodeLine{00093\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00671_a463cbd4685551c74125ff89060de20cd}{LongToDouble}}\ (int32\_t\ aLong)}
\DoxyCodeLine{00094\ \{}
\DoxyCodeLine{00095\ \ \ \ \ \textcolor{keywordflow}{if}\ (aLong\ >\ \mbox{\hyperlink{a00671_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}})}
\DoxyCodeLine{00096\ \ \ \ \ \ \ \ \ aLong\ =\ \mbox{\hyperlink{a00671_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}};}
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (aLong\ <\ \mbox{\hyperlink{a00671_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}})}
\DoxyCodeLine{00098\ \ \ \ \ \ \ \ \ aLong\ =\ \mbox{\hyperlink{a00671_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}};}
\DoxyCodeLine{00099\ \ \ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{double}(aLong)\ *\ \mbox{\hyperlink{a00671_a5ad86b72eda6b0e72864ec774adad1cf}{kOneOver56kFracAbsMax}});}
\DoxyCodeLine{00100\ \}}
\DoxyCodeLine{00101\ }
\DoxyCodeLine{00104\ int32\_t\ \mbox{\hyperlink{a00671_a59b4dba8d35a4837ab0afe3886bec74a}{DoubleToLong}}\ (\textcolor{keywordtype}{double}\ aDouble);}
\DoxyCodeLine{00105\ \ \ \ \ }
\DoxyCodeLine{00108\ \textcolor{keyword}{inline}\ int32\_t\ \mbox{\hyperlink{a00671_a1567c2393df9139b20166027d0127195}{DoubleToDSPCoef}}(\textcolor{keywordtype}{double}\ d,\ \textcolor{keywordtype}{double}\ max\ =\ \mbox{\hyperlink{a00671_abc7ad084f4b51c70feeac700ab05f7a5}{k56kFloatPosMax}},\ \textcolor{keywordtype}{double}\ min\ =\ \mbox{\hyperlink{a00671_ae1518eaa8f13def92b4c9daeedbbe002}{k56kFloatNegMax}})}
\DoxyCodeLine{00109\ \{}
\DoxyCodeLine{00110\ \ \ \ \ \textcolor{keywordflow}{if}(d\ >=\ max)\ \textcolor{comment}{//\ k56kFloatPosMax\ unless\ specified\ by\ the\ caller}}
\DoxyCodeLine{00111\ \ \ \ \ \{}
\DoxyCodeLine{00112\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00671_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}};\ \ \ \ }
\DoxyCodeLine{00113\ \ \ \ \ \};}
\DoxyCodeLine{00114\ \ \ \ \ \textcolor{keywordflow}{if}(d\ <\ min)\ \textcolor{comment}{//\ k56kFloatNegMax\ unless\ specified\ by\ the\ caller}}
\DoxyCodeLine{00115\ \ \ \ \ \{}
\DoxyCodeLine{00116\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00671_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}};\ \ \ \ }
\DoxyCodeLine{00117\ \ \ \ \ \}}
\DoxyCodeLine{00118\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}int32\_t\textcolor{keyword}{>}(d*\mbox{\hyperlink{a00671_ad6054f9b9b26d0b3ee01a6ef097afaea}{k56kFracAbsMax}});}
\DoxyCodeLine{00119\ \}}
\DoxyCodeLine{00120\ }
\DoxyCodeLine{00123\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00671_a5e9c399a10a03718eaaf71cfcddd583f}{DSPCoefToDouble}}(int32\_t\ c,\ int32\_t\ max\ =\ \mbox{\hyperlink{a00671_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}},\ int32\_t\ min\ =\ \mbox{\hyperlink{a00671_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}})}
\DoxyCodeLine{00124\ \{}
\DoxyCodeLine{00125\ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ >\ max)\ \textcolor{comment}{//\ k56kFracPosMax\ unless\ specified\ by\ the\ caller}}
\DoxyCodeLine{00126\ \ \ \ \ \ \ \ \ c\ =\ \mbox{\hyperlink{a00671_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}};}
\DoxyCodeLine{00127\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (c\ <\ min)\ \textcolor{comment}{//\ k56kFracNegMax\ unless\ specified\ by\ the\ caller}}
\DoxyCodeLine{00128\ \ \ \ \ \ \ \ \ c\ =\ \mbox{\hyperlink{a00671_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}};}
\DoxyCodeLine{00129\ \ \ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{double}(c)\ *\ \mbox{\hyperlink{a00671_a5ad86b72eda6b0e72864ec774adad1cf}{kOneOver56kFracAbsMax}});}
\DoxyCodeLine{00130\ \}}
\DoxyCodeLine{00131\ }
\DoxyCodeLine{00134\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00671_a52514266bf44c844934aedcd6975037d}{ThirtyTwoBitDSPCoefToDouble}}(int32\_t\ c)}
\DoxyCodeLine{00135\ \{}
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00671_a5e9c399a10a03718eaaf71cfcddd583f}{DSPCoefToDouble}}(c,\ \mbox{\hyperlink{a00671_a6758dcc7fe73efcefb9980ff895c36d0}{k32BitPosMax}},\ \mbox{\hyperlink{a00671_a4623748ef4a22daea8cbbf7557ecb60e}{k32BitNegMax}});}
\DoxyCodeLine{00137\ \}}
\DoxyCodeLine{00138\ }
\DoxyCodeLine{00141\ \textcolor{keyword}{inline}\ int32\_t\ \mbox{\hyperlink{a00671_ab8477bacb0294598f49057507fb17810}{DoubleTo32BitDSPCoefRnd}}(\textcolor{keywordtype}{double}\ d)}
\DoxyCodeLine{00142\ \{}
\DoxyCodeLine{00143\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00671_a1567c2393df9139b20166027d0127195}{DoubleToDSPCoef}}(d,\ \mbox{\hyperlink{a00671_a6758dcc7fe73efcefb9980ff895c36d0}{k32BitPosMax}},\ \mbox{\hyperlink{a00671_a4623748ef4a22daea8cbbf7557ecb60e}{k32BitNegMax}});}
\DoxyCodeLine{00144\ \}}
\DoxyCodeLine{00145\ }
\DoxyCodeLine{00146\ int32\_t\ \mbox{\hyperlink{a00671_ac7d80281cdc671669f3f2d523b2960cf}{DoubleTo32BitDSPCoef}}(\textcolor{keywordtype}{double}\ d);}
\DoxyCodeLine{00147\ int32\_t\ \mbox{\hyperlink{a00671_a3db78a10d239924fd403b9d2fed5b296}{DoubleToDSPCoefRnd}}(\textcolor{keywordtype}{double}\ d,\ \textcolor{keywordtype}{double}\ max,\ \textcolor{keywordtype}{double}\ min);}
\DoxyCodeLine{00148\ }
\DoxyCodeLine{00149\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ AAX\_COMMONCONVERIONS\_H}}

\end{DoxyCode}
