\hypertarget{a00659_source}{}\doxysection{AAX\+\_\+\+Common\+Conversions.\+h}
\label{a00659_source}\index{AAX\_CommonConversions.h@{AAX\_CommonConversions.h}}
\mbox{\hyperlink{a00659}{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\ Avid\ Technology,\ Inc.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *\ \ All\ rights\ reserved.}}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ \ CONFIDENTIAL:\ this\ document\ contains\ confidential\ information\ of\ Avid.\ Do}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ \ not\ disclose\ to\ any\ third\ party.\ Use\ of\ the\ information\ contained\ in\ this}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *\ \ document\ is\ subject\ to\ an\ Avid\ SDK\ license.}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00011\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00012\ }
\DoxyCodeLine{00017\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00018\ }
\DoxyCodeLine{00019\ }
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#ifndef\ AAX\_COMMONCONVERIONS\_H}}
\DoxyCodeLine{00021\ \textcolor{preprocessor}{\#define\ AAX\_COMMONCONVERIONS\_H}}
\DoxyCodeLine{00022\ }
\DoxyCodeLine{00023\ \textcolor{preprocessor}{\#include\ <math.h>}}
\DoxyCodeLine{00024\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00533}{AAX.h}}"{}}}
\DoxyCodeLine{00025\ }
\DoxyCodeLine{00026\ }
\DoxyCodeLine{00027\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00659_a6758dcc7fe73efcefb9980ff895c36d0}{k32BitPosMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x7FFFFFFF;}
\DoxyCodeLine{00028\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00659_a19c3de953254f182959cb74c9f6ed055}{k32BitAbsMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x80000000;}
\DoxyCodeLine{00029\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00659_a4623748ef4a22daea8cbbf7557ecb60e}{k32BitNegMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x80000000;}
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00031\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00659_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x007FFFFF;\ \ \ \textcolor{comment}{//\ Positive\ Max\ Value\ }}
\DoxyCodeLine{00032\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00659_ad6054f9b9b26d0b3ee01a6ef097afaea}{k56kFracAbsMax}}\ \ \ \ \ \ \ \ \ \ =\ 0x00800000;\ \ \ \textcolor{comment}{//\ Absolute\ Max\ Value.\ Essentially\ negative\ one\ without\ the\ sign\ extension.}}
\DoxyCodeLine{00033\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00659_a485384e2f324b1666ad9d8600c442d61}{k56kFracHalf}}\ \ \ \ \ \ \ \ \ \ =\ 0x00400000;}
\DoxyCodeLine{00034\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00659_affbe56efc7321622e3d4c1e2ef60cb28}{k56kFracNegOne}}\ \ \ \ \ \ \ \ \ \ =\ 0xFF800000;\ \ \ \textcolor{comment}{//Note\ sign\ extension!!!}}
\DoxyCodeLine{00035\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00659_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}}\ \ \ \ \ \ \ \ \ \ =\ \mbox{\hyperlink{a00659_affbe56efc7321622e3d4c1e2ef60cb28}{k56kFracNegOne}};\ \textcolor{comment}{//Note\ sign\ extension!!!}}
\DoxyCodeLine{00036\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00659_aeb01246d63cd5b5d1b6c6eb5bcd08b8b}{k56kFracZero}}\ \ \ \ \ \ \ \ \ \ =\ 0x00000000;}
\DoxyCodeLine{00037\ }
\DoxyCodeLine{00038\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00659_a5ad86b72eda6b0e72864ec774adad1cf}{kOneOver56kFracAbsMax}}\ =\ 1.0/double(\mbox{\hyperlink{a00659_ad6054f9b9b26d0b3ee01a6ef097afaea}{k56kFracAbsMax}});}
\DoxyCodeLine{00039\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00659_abc7ad084f4b51c70feeac700ab05f7a5}{k56kFloatPosMax}}\ \ \ \ \ =\ double(\mbox{\hyperlink{a00659_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}})/double(\mbox{\hyperlink{a00659_ad6054f9b9b26d0b3ee01a6ef097afaea}{k56kFracAbsMax}});\ \ \ \ \ \ \ \ \textcolor{comment}{//56k\ Max\ value\ represented\ in\ floating\ point\ format.}}
\DoxyCodeLine{00040\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00659_ae1518eaa8f13def92b4c9daeedbbe002}{k56kFloatNegMax}}\ \ \ \ \ =\ -\/1.0;\ \ \ \ \ \textcolor{comment}{//56k\ Min\ value\ represented\ in\ floating\ point\ format.}}
\DoxyCodeLine{00041\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00659_a2381bc3bc0a4c5e07bf67baf7d440137}{kNeg144DB}}\ \ \ \ \ \ \ \ \ \ \ \ \ =\ -\/144.0;}
\DoxyCodeLine{00042\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00659_a1baf8195909ae1265cbb609e6702d2b4}{kNeg144Gain}}\ \ \ \ \ \ \ \ \ =\ 6.3095734448019324943436013662234e-\/8;\ \textcolor{comment}{//pow(10.0,\ kNeg144DB\ /\ 20.0);}}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00049\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \ \ \mbox{\hyperlink{a00659_a76f29f12e35c093e5c198b8d0e27b6f9}{GainToDB}}(\textcolor{keywordtype}{double}\ aGain)}
\DoxyCodeLine{00050\ \{}
\DoxyCodeLine{00051\ \ \ \ \ \textcolor{keywordflow}{if}\ (aGain\ ==\ 0.0)}
\DoxyCodeLine{00052\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00659_a2381bc3bc0a4c5e07bf67baf7d440137}{kNeg144DB}};}
\DoxyCodeLine{00053\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00054\ \ \ \ \ \{}
\DoxyCodeLine{00055\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{double}\ \ dB;}
\DoxyCodeLine{00056\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00057\ \ \ \ \ \ \ \ \ dB\ =\ log10(aGain)\ *\ 20.0;}
\DoxyCodeLine{00058\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00059\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (dB\ <\ \mbox{\hyperlink{a00659_a2381bc3bc0a4c5e07bf67baf7d440137}{kNeg144DB}})}
\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ \ \ \ \ dB\ =\ \mbox{\hyperlink{a00659_a2381bc3bc0a4c5e07bf67baf7d440137}{kNeg144DB}};}
\DoxyCodeLine{00061\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ (dB);\ \ \ \ \ \ \ \ \textcolor{comment}{//\ convert\ factor\ to\ dB}}
\DoxyCodeLine{00062\ \ \ \ \ \}}
\DoxyCodeLine{00063\ \}}
\DoxyCodeLine{00064\ }
\DoxyCodeLine{00070\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00659_a596d5ea393d43f6f798a838aefe3cecd}{DBToGain}}(\textcolor{keywordtype}{double}\ dB)}
\DoxyCodeLine{00071\ \{}
\DoxyCodeLine{00072\ \ \ \ \ \textcolor{keywordflow}{return}\ pow(10.0,\ dB\ /\ 20.0);}
\DoxyCodeLine{00073\ \}}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00080\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00659_a463cbd4685551c74125ff89060de20cd}{LongToDouble}}\ (int32\_t\ aLong)}
\DoxyCodeLine{00081\ \{}
\DoxyCodeLine{00082\ \ \ \ \ \textcolor{keywordflow}{if}\ (aLong\ >\ \mbox{\hyperlink{a00659_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}})}
\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ aLong\ =\ \mbox{\hyperlink{a00659_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}};}
\DoxyCodeLine{00084\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (aLong\ <\ \mbox{\hyperlink{a00659_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}})}
\DoxyCodeLine{00085\ \ \ \ \ \ \ \ \ aLong\ =\ \mbox{\hyperlink{a00659_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}};}
\DoxyCodeLine{00086\ \ \ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{double}(aLong)\ *\ \mbox{\hyperlink{a00659_a5ad86b72eda6b0e72864ec774adad1cf}{kOneOver56kFracAbsMax}});}
\DoxyCodeLine{00087\ \}}
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00091\ int32\_t\ \mbox{\hyperlink{a00659_a59b4dba8d35a4837ab0afe3886bec74a}{DoubleToLong}}\ (\textcolor{keywordtype}{double}\ aDouble);}
\DoxyCodeLine{00092\ \ \ \ \ }
\DoxyCodeLine{00095\ \textcolor{keyword}{inline}\ int32\_t\ \mbox{\hyperlink{a00659_a1567c2393df9139b20166027d0127195}{DoubleToDSPCoef}}(\textcolor{keywordtype}{double}\ d,\ \textcolor{keywordtype}{double}\ max\ =\ \mbox{\hyperlink{a00659_abc7ad084f4b51c70feeac700ab05f7a5}{k56kFloatPosMax}},\ \textcolor{keywordtype}{double}\ min\ =\ \mbox{\hyperlink{a00659_ae1518eaa8f13def92b4c9daeedbbe002}{k56kFloatNegMax}})}
\DoxyCodeLine{00096\ \{}
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{keywordflow}{if}(d\ >=\ max)\ \textcolor{comment}{//\ k56kFloatPosMax\ unless\ specified\ by\ the\ caller}}
\DoxyCodeLine{00098\ \ \ \ \ \{}
\DoxyCodeLine{00099\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00659_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}};\ \ \ \ }
\DoxyCodeLine{00100\ \ \ \ \ \};}
\DoxyCodeLine{00101\ \ \ \ \ \textcolor{keywordflow}{if}(d\ <\ min)\ \textcolor{comment}{//\ k56kFloatNegMax\ unless\ specified\ by\ the\ caller}}
\DoxyCodeLine{00102\ \ \ \ \ \{}
\DoxyCodeLine{00103\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00659_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}};\ \ \ \ }
\DoxyCodeLine{00104\ \ \ \ \ \}}
\DoxyCodeLine{00105\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}int32\_t\textcolor{keyword}{>}(d*\mbox{\hyperlink{a00659_ad6054f9b9b26d0b3ee01a6ef097afaea}{k56kFracAbsMax}});}
\DoxyCodeLine{00106\ \}}
\DoxyCodeLine{00107\ }
\DoxyCodeLine{00110\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00659_a5e9c399a10a03718eaaf71cfcddd583f}{DSPCoefToDouble}}(int32\_t\ c,\ int32\_t\ max\ =\ \mbox{\hyperlink{a00659_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}},\ int32\_t\ min\ =\ \mbox{\hyperlink{a00659_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}})}
\DoxyCodeLine{00111\ \{}
\DoxyCodeLine{00112\ \ \ \ \ \textcolor{keywordflow}{if}\ (c\ >\ max)\ \textcolor{comment}{//\ k56kFracPosMax\ unless\ specified\ by\ the\ caller}}
\DoxyCodeLine{00113\ \ \ \ \ \ \ \ \ c\ =\ \mbox{\hyperlink{a00659_aa1f75eeb19dad78b3045cb5778421b61}{k56kFracPosMax}};}
\DoxyCodeLine{00114\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (c\ <\ min)\ \textcolor{comment}{//\ k56kFracNegMax\ unless\ specified\ by\ the\ caller}}
\DoxyCodeLine{00115\ \ \ \ \ \ \ \ \ c\ =\ \mbox{\hyperlink{a00659_a3306ddeeab535815290a268837e276b1}{k56kFracNegMax}};}
\DoxyCodeLine{00116\ \ \ \ \ \textcolor{keywordflow}{return}\ (\textcolor{keywordtype}{double}(c)\ *\ \mbox{\hyperlink{a00659_a5ad86b72eda6b0e72864ec774adad1cf}{kOneOver56kFracAbsMax}});}
\DoxyCodeLine{00117\ \}}
\DoxyCodeLine{00118\ }
\DoxyCodeLine{00121\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{a00659_a52514266bf44c844934aedcd6975037d}{ThirtyTwoBitDSPCoefToDouble}}(int32\_t\ c)}
\DoxyCodeLine{00122\ \{}
\DoxyCodeLine{00123\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00659_a5e9c399a10a03718eaaf71cfcddd583f}{DSPCoefToDouble}}(c,\ \mbox{\hyperlink{a00659_a6758dcc7fe73efcefb9980ff895c36d0}{k32BitPosMax}},\ \mbox{\hyperlink{a00659_a4623748ef4a22daea8cbbf7557ecb60e}{k32BitNegMax}});}
\DoxyCodeLine{00124\ \}}
\DoxyCodeLine{00125\ }
\DoxyCodeLine{00128\ \textcolor{keyword}{inline}\ int32\_t\ \mbox{\hyperlink{a00659_ab8477bacb0294598f49057507fb17810}{DoubleTo32BitDSPCoefRnd}}(\textcolor{keywordtype}{double}\ d)}
\DoxyCodeLine{00129\ \{}
\DoxyCodeLine{00130\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00659_a1567c2393df9139b20166027d0127195}{DoubleToDSPCoef}}(d,\ \mbox{\hyperlink{a00659_a6758dcc7fe73efcefb9980ff895c36d0}{k32BitPosMax}},\ \mbox{\hyperlink{a00659_a4623748ef4a22daea8cbbf7557ecb60e}{k32BitNegMax}});}
\DoxyCodeLine{00131\ \}}
\DoxyCodeLine{00132\ }
\DoxyCodeLine{00133\ int32\_t\ \mbox{\hyperlink{a00659_ac7d80281cdc671669f3f2d523b2960cf}{DoubleTo32BitDSPCoef}}(\textcolor{keywordtype}{double}\ d);}
\DoxyCodeLine{00134\ int32\_t\ \mbox{\hyperlink{a00659_a3db78a10d239924fd403b9d2fed5b296}{DoubleToDSPCoefRnd}}(\textcolor{keywordtype}{double}\ d,\ \textcolor{keywordtype}{double}\ max,\ \textcolor{keywordtype}{double}\ min);}
\DoxyCodeLine{00135\ }
\DoxyCodeLine{00136\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ AAX\_COMMONCONVERIONS\_H}}

\end{DoxyCode}
