\hypertarget{a00857_source}{}\doxysection{AAX\+\_\+\+Random\+Gen.\+h}
\label{a00857_source}\index{AAX\_RandomGen.h@{AAX\_RandomGen.h}}
\mbox{\hyperlink{a00857}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ \ Copyright\ 2013-\/2015,\ 2023-\/2024\ Avid\ Technology,\ Inc.}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ \ All\ rights\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ \ This\ file\ is\ part\ of\ the\ Avid\ AAX\ SDK.}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ \ The\ AAX\ SDK\ is\ subject\ to\ commercial\ or\ open-\/source\ licensing.}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *\ \ By\ using\ the\ AAX\ SDK,\ you\ agree\ to\ the\ terms\ of\ both\ the\ Avid\ AAX\ SDK\ License}}
\DoxyCodeLine{00011\ \textcolor{comment}{\ *\ \ Agreement\ and\ Avid\ Privacy\ Policy.}}
\DoxyCodeLine{00012\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00013\ \textcolor{comment}{\ *\ \ AAX\ SDK\ License:\ https://developer.avid.com/aax}}
\DoxyCodeLine{00014\ \textcolor{comment}{\ *\ \ Privacy\ Policy:\ https://www.avid.com/legal/privacy-\/policy-\/statement}}
\DoxyCodeLine{00015\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00016\ \textcolor{comment}{\ *\ \ Or:\ You\ may\ also\ use\ this\ code\ under\ the\ terms\ of\ the\ GPL\ v3\ (see}}
\DoxyCodeLine{00017\ \textcolor{comment}{\ *\ \ www.gnu.org/licenses).}}
\DoxyCodeLine{00018\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00019\ \textcolor{comment}{\ *\ \ THE\ AAX\ SDK\ IS\ PROVIDED\ "{}AS\ IS"{}\ WITHOUT\ ANY\ WARRANTY,\ AND\ ALL\ WARRANTIES,\ WHETHER}}
\DoxyCodeLine{00020\ \textcolor{comment}{\ *\ \ EXPRESSED\ OR\ IMPLIED,\ INCLUDING\ MERCHANTABILITY\ AND\ FITNESS\ FOR\ PURPOSE,\ ARE}}
\DoxyCodeLine{00021\ \textcolor{comment}{\ *\ \ DISCLAIMED.}}
\DoxyCodeLine{00022\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00030\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00031\ \textcolor{preprocessor}{\#pragma\ once}}
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00033\ \textcolor{preprocessor}{\#ifndef\ AAX\_RANDOMGEN\_H}}
\DoxyCodeLine{00034\ \textcolor{preprocessor}{\#define\ AAX\_RANDOMGEN\_H}}
\DoxyCodeLine{00035\ }
\DoxyCodeLine{00036\ \textcolor{comment}{//\ Standard\ headers}}
\DoxyCodeLine{00037\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{00038\ \textcolor{preprocessor}{\#include\ <time.h>}}
\DoxyCodeLine{00039\ \textcolor{preprocessor}{\#include\ <stdint.h>}}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00041\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00845}{AAX\_PlatformOptimizationConstants.h}}"{}}}
\DoxyCodeLine{00042\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00842}{AAX\_Constants.h}}"{}}}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00044\ \textcolor{keyword}{namespace\ }\mbox{\hyperlink{a00948}{AAX}}}
\DoxyCodeLine{00045\ \{}
\DoxyCodeLine{00046\ }
\DoxyCodeLine{00047\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00948_a0c975151f0d47cc80eef9ff5a7c80125}{cSeedDivisor}}\ =\ 1/127773.0f;}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ \textcolor{keyword}{const}\ int32\_t\ \mbox{\hyperlink{a00948_a143d659ccb62ae0807e9902e751b14cf}{cInitialSeedValue}}=0x00F54321;}
\DoxyCodeLine{00050\ }
\DoxyCodeLine{00051\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00052\ \textcolor{keyword}{inline}\ int32\_t\ \mbox{\hyperlink{a00948_af3435129d3c94c5f3d5e671943b9bbe2}{GetInt32RPDF}}(int32\_t*\ iSeed)}
\DoxyCodeLine{00053\ \{}
\DoxyCodeLine{00054\ \ \ \ \ \textcolor{comment}{//\ Requirement:\ iSeed\ param\ must\ be\ a\ static\ in\ the\ calling\ function.}}
\DoxyCodeLine{00055\ \ \ \ \ int64\_t\ seed\ =\ *iSeed;}
\DoxyCodeLine{00056\ \ \ \ \ int64\_t\ k\ =\ \textcolor{keyword}{static\_cast<}int64\_t\textcolor{keyword}{>}(seed*\mbox{\hyperlink{a00948_a0c975151f0d47cc80eef9ff5a7c80125}{cSeedDivisor}});}
\DoxyCodeLine{00057\ \ \ \ \ seed\ =\ 16807\ *\ (seed\ -\/\ k\ *\ 127773LL)\ -\/\ 2836\ *\ k\ +\ 7395;}
\DoxyCodeLine{00058\ \ \ \ \ *iSeed\ =\ \textcolor{keyword}{static\_cast<}int32\_t\textcolor{keyword}{>}(seed);}
\DoxyCodeLine{00059\ \ \ \ \ \textcolor{keywordflow}{if}\ (*iSeed\ <\ 0)\ }
\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ *iSeed\ +=\ 2147483647;}
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{keywordflow}{return}\ (*iSeed\ -\/\ 1073741824)\ *\ 2;\ \ \ \ \ \ \ \textcolor{comment}{//\ -\/2147483647..+2147483647}}
\DoxyCodeLine{00062\ \}}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00064\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00065\ }
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00079\ \textcolor{keyword}{inline}\ int32\_t\ \mbox{\hyperlink{a00948_ad12251899137d551b9f652b1ffee2f99}{GetFastInt32RPDF}}(int32\_t*\ iSeed)}
\DoxyCodeLine{00080\ \{}
\DoxyCodeLine{00081\ \ \ \ *iSeed\ =\ (*iSeed\ *\ 196314165)\ +\ 907633515;}
\DoxyCodeLine{00082\ \ \ \ \textcolor{keywordflow}{return}\ *iSeed;}
\DoxyCodeLine{00083\ \}}
\DoxyCodeLine{00084\ }
\DoxyCodeLine{00085\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00086\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00948_a5a91375167236862abc93ad879639cab}{GetRPDFWithAmplitudeOneHalf}}(int32\_t*\ iSeed)\ \ \ \ \ \textcolor{comment}{//An\ amplitude\ of\ 0.5\ =\ 1\ LSBs}}
\DoxyCodeLine{00087\ \{}
\DoxyCodeLine{00088\ \ \ \ \ \textcolor{comment}{//\ Requirement:\ iSeed\ param\ must\ be\ a\ static\ in\ the\ calling\ function.}}
\DoxyCodeLine{00089\ \ \ \ \ \textcolor{keywordflow}{return}\ float(\mbox{\hyperlink{a00948_a93ce2d3935dc06b1c4c887568df84788}{cNormalizeLongToAmplitudeOneHalf}})\ *\ float(\mbox{\hyperlink{a00948_af3435129d3c94c5f3d5e671943b9bbe2}{GetInt32RPDF}}(iSeed));}
\DoxyCodeLine{00090\ \}}
\DoxyCodeLine{00091\ }
\DoxyCodeLine{00092\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00093\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00948_a51d7a263d9053276c6cef1dbd2018ebe}{GetRPDFWithAmplitudeOne}}(int32\_t*\ iSeed)\ \ \ \ \ \ \ \ \ \textcolor{comment}{//An\ amplitude\ of\ 1.0\ =\ 2\ LSBs}}
\DoxyCodeLine{00094\ \{}
\DoxyCodeLine{00095\ \ \ \ \ \textcolor{comment}{//\ Requirement:\ iSeed\ param\ must\ be\ a\ static\ in\ the\ calling\ function.}}
\DoxyCodeLine{00096\ \ \ \ \ \textcolor{keywordflow}{return}\ float(\mbox{\hyperlink{a00948_ad30333177ff94148492a02325045a827}{cNormalizeLongToAmplitudeOne}})\ *\ float(\mbox{\hyperlink{a00948_af3435129d3c94c5f3d5e671943b9bbe2}{GetInt32RPDF}}(iSeed));}
\DoxyCodeLine{00097\ \}}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00099\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00100\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00948_a145cc6d06cd682e2d234d07ce939760e}{GetFastRPDFWithAmplitudeOne}}(int32\_t*\ iSeed)\ \ \ \ \ \ \ \ \ \textcolor{comment}{//An\ amplitude\ of\ 1.0\ =\ 2\ LSBs}}
\DoxyCodeLine{00101\ \{}
\DoxyCodeLine{00102\ \ \ \ \ \textcolor{comment}{//\ Requirement:\ iSeed\ param\ must\ be\ a\ static\ in\ the\ calling\ function.}}
\DoxyCodeLine{00103\ \ \ \ \ \textcolor{keywordflow}{return}\ float(\mbox{\hyperlink{a00948_ad30333177ff94148492a02325045a827}{cNormalizeLongToAmplitudeOne}})\ *\ float(\mbox{\hyperlink{a00948_ad12251899137d551b9f652b1ffee2f99}{GetFastInt32RPDF}}(iSeed));}
\DoxyCodeLine{00104\ \}}
\DoxyCodeLine{00105\ }
\DoxyCodeLine{00106\ \textcolor{comment}{/*===================================================================================================*/}}
\DoxyCodeLine{00107\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ \mbox{\hyperlink{a00948_a42cc414ea1b868e26c591041a66ad8af}{GetTPDFWithAmplitudeOne}}(int32\_t*\ iSeed)\ \ \ \ \ \ \ \ \ \textcolor{comment}{//An\ amplitude\ of\ 1.0\ =\ 2\ LSBs}}
\DoxyCodeLine{00108\ \{}
\DoxyCodeLine{00109\ \ \ \ \ \textcolor{comment}{//\ Generate\ a\ random\ number\ with\ a\ triangular\ pdf\ (tpdf)\ using\ two\ }}
\DoxyCodeLine{00110\ \ \ \ \ \textcolor{comment}{//\ separate\ rectangular\ pdf\ noise\ sources.}}
\DoxyCodeLine{00111\ }
\DoxyCodeLine{00112\ \ \ \ \ \textcolor{comment}{//\ We\ are\ using\ only\ one\ seed\ input\ for\ both\ rect\ pdf\ noise\ generators,\ }}
\DoxyCodeLine{00113\ \ \ \ \ \textcolor{comment}{//\ but\ because\ they\ are\ of\ course\ executed\ sequentially\ independent\ noise\ }}
\DoxyCodeLine{00114\ \ \ \ \ \textcolor{comment}{//\ will\ be\ produced.}}
\DoxyCodeLine{00115\ }
\DoxyCodeLine{00116\ \ \ \ \ \textcolor{keywordflow}{return}\ float(\mbox{\hyperlink{a00948_ad30333177ff94148492a02325045a827}{cNormalizeLongToAmplitudeOne}})\ *\ (float(\mbox{\hyperlink{a00948_ad12251899137d551b9f652b1ffee2f99}{GetFastInt32RPDF}}(iSeed)\ +\ \textcolor{keywordtype}{float}(\mbox{\hyperlink{a00948_ad12251899137d551b9f652b1ffee2f99}{GetFastInt32RPDF}}(iSeed))));}
\DoxyCodeLine{00117\ \}}
\DoxyCodeLine{00118\ }
\DoxyCodeLine{00119\ \}\ \textcolor{comment}{//\ namespace\ AAX}}
\DoxyCodeLine{00120\ }
\DoxyCodeLine{00121\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ AAX\_RANDOMGEN\_H}}
\DoxyCodeLine{00122\ }

\end{DoxyCode}
