\hypertarget{a00872_source}{}\doxysection{AAX\+\_\+\+Sample\+Rate\+Utils.\+h}
\label{a00872_source}\index{AAX\_SampleRateUtils.h@{AAX\_SampleRateUtils.h}}
\mbox{\hyperlink{a00872}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ \ Copyright\ 2009-\/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{keyword}{enum}\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3e}{ESRUtils}}}
\DoxyCodeLine{00034\ \{}
\DoxyCodeLine{00035\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eae974abf255ac5507a0c8163d0ebf9bcb}{eSRUtils\_48kRangeCoarse}}\ \ \ \ \ \ =\ 48000,}
\DoxyCodeLine{00036\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea376e9c46e970aa93e789445670b1d45f}{eSRUtils\_96kRangeCoarse}}\ \ \ \ \ \ =\ 96000,}
\DoxyCodeLine{00037\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eadc3653ea09f8a83c8222afc5a386e28f}{eSRUtils\_192kRangeCoarse}}\ \ \ \ =\ 192000,}
\DoxyCodeLine{00038\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eaec0fdd5b4e84f205ff16852740f18ea2}{eSRUtils\_48kRangeMin}}\ \ \ \ \ \ \ \ =\ 0,}
\DoxyCodeLine{00039\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea1676c77c5473c1f0b7e820150869d413}{eSRUtils\_48kRangeMax}}\ \ \ \ \ \ \ \ =\ 51000,}
\DoxyCodeLine{00040\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea858679d6660025243d5e9b0f06797f7f}{eSRUtils\_96kRangeMin}}\ \ \ \ \ \ \ \ =\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea1676c77c5473c1f0b7e820150869d413}{eSRUtils\_48kRangeMax}}+1,}
\DoxyCodeLine{00041\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eabc1086d9707a35f99ed52f59b6b14934}{eSRUtils\_96kRangeMax}}\ \ \ \ \ \ \ \ =\ 102000,}
\DoxyCodeLine{00042\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea675774f7e038af726de7561dcd3f314b}{eSRUtils\_192kRangeMin}}\ \ \ \ \ \ =\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eabc1086d9707a35f99ed52f59b6b14934}{eSRUtils\_96kRangeMax}}+1,}
\DoxyCodeLine{00043\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eaac7e670dc4a1cc396be2fd024f6a237f}{eSRUtils\_192kRangeMax}}\ \ \ \ \ \ =\ 204000,}
\DoxyCodeLine{00044\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eaa501e86b22b5be0d003d73ad5fd4e1f5}{eSRUtils\_48kIndex}}\ \ \ \ \ \ =\ 0,}
\DoxyCodeLine{00045\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea0cb96ccca8f89676f461df0054ee2678}{eSRUtils\_96kIndex}}\ \ \ \ \ \ =\ 1,}
\DoxyCodeLine{00046\ \ \ \ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eafdb7fb04ad5032eeccbeec8d26a4a04c}{eSRUtils\_192kIndex}}\ \ \ \ \ \ \ \ =\ 2}
\DoxyCodeLine{00047\ \};}
\DoxyCodeLine{00048\ \ \ \ \ }
\DoxyCodeLine{00049\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{a00872_ab463c18c13ba2c75b89da6c90f02d0f0}{CoarseSampleRate}}\ (\textcolor{keywordtype}{int}\ iRate)}
\DoxyCodeLine{00050\ \{}
\DoxyCodeLine{00051\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ aCoarseRate\ =}
\DoxyCodeLine{00052\ }
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ ((iRate\ >=\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eaec0fdd5b4e84f205ff16852740f18ea2}{eSRUtils\_48kRangeMin}})\ \&\&\ (iRate\ <=\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea1676c77c5473c1f0b7e820150869d413}{eSRUtils\_48kRangeMax}}))\ ?\ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eae974abf255ac5507a0c8163d0ebf9bcb}{eSRUtils\_48kRangeCoarse}}\ :}
\DoxyCodeLine{00054\ \ \ \ \ \ \ \ \ ((iRate\ >=\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea858679d6660025243d5e9b0f06797f7f}{eSRUtils\_96kRangeMin}})\ \&\&\ (iRate\ <=\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eabc1086d9707a35f99ed52f59b6b14934}{eSRUtils\_96kRangeMax}}))\ ?\ \ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea376e9c46e970aa93e789445670b1d45f}{eSRUtils\_96kRangeCoarse}}\ :}
\DoxyCodeLine{00055\ \ \ \ \ \ \ \ \ ((iRate\ >=\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea675774f7e038af726de7561dcd3f314b}{eSRUtils\_192kRangeMin}})\ \&\&\ (iRate\ <=\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eaac7e670dc4a1cc396be2fd024f6a237f}{eSRUtils\_192kRangeMax}}))\ ?\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eadc3653ea09f8a83c8222afc5a386e28f}{eSRUtils\_192kRangeCoarse}}\ :}
\DoxyCodeLine{00056\ \ \ \ \ \ \ \ \ 0;}
\DoxyCodeLine{00057\ }
\DoxyCodeLine{00058\ \ \ \ \ \textcolor{keywordflow}{if}\ (aCoarseRate\ ==\ 0)}
\DoxyCodeLine{00059\ \ \ \ \ \{}
\DoxyCodeLine{00060\ \textcolor{comment}{//\ \ \ \ \ \ throw\ std::runtime\_error\ ("{}unrecognized\ sample\ rate"{});}}
\DoxyCodeLine{00061\ \ \ \ \ \}}
\DoxyCodeLine{00062\ \ \ \ \ \textcolor{keywordflow}{return}\ aCoarseRate;}
\DoxyCodeLine{00063\ \}}
\DoxyCodeLine{00064\ }
\DoxyCodeLine{00065\ \textcolor{comment}{//Returns\ 1\ for\ 48k,\ 2\ for\ 96k,\ and\ 4\ for\ 192k\ gross\ samples\ rate.}}
\DoxyCodeLine{00066\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{a00872_a781f007f979a98d27156a4675fd853fa}{CoarseSampleRateFactor}}\ (\textcolor{keywordtype}{int}\ iRate)}
\DoxyCodeLine{00067\ \{}
\DoxyCodeLine{00068\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ kMinCoarseSampleRate=\mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eae974abf255ac5507a0c8163d0ebf9bcb}{eSRUtils\_48kRangeCoarse}};}
\DoxyCodeLine{00069\ }
\DoxyCodeLine{00070\ \ \ \ \ \textcolor{keywordtype}{int}\ aCoarseRateFactor\ =\ \mbox{\hyperlink{a00872_ab463c18c13ba2c75b89da6c90f02d0f0}{CoarseSampleRate}}\ (iRate)/kMinCoarseSampleRate;}
\DoxyCodeLine{00071\ }
\DoxyCodeLine{00072\ \ \ \ \ \textcolor{keywordflow}{return}\ aCoarseRateFactor;}
\DoxyCodeLine{00073\ \}}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \textcolor{comment}{//Returns\ 0\ for\ 48k,\ 1\ for\ 96k,\ and\ 2\ for\ 192k\ gross\ samples\ rate.}}
\DoxyCodeLine{00076\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{a00872_a149fe437454807a2d3edacf8de72c2a1}{CoarseSampleRateIndex}}\ (\textcolor{keywordtype}{int}\ iRate)}
\DoxyCodeLine{00077\ \{}
\DoxyCodeLine{00078\ \textcolor{comment}{//\ \ const\ long\ kMinGrossSampleRate=eSRUtils\_48kRangeCoarse;}}
\DoxyCodeLine{00079\ \ \ \ \ \textcolor{keywordtype}{int}\ aGrossRateIndex\ =\ 0;}
\DoxyCodeLine{00080\ }
\DoxyCodeLine{00081\ \ \ \ \ \textcolor{keywordflow}{switch}\ (\ \mbox{\hyperlink{a00872_ab463c18c13ba2c75b89da6c90f02d0f0}{CoarseSampleRate}}\ (iRate)\ )}
\DoxyCodeLine{00082\ \ \ \ \ \{}
\DoxyCodeLine{00083\ \ \ \ \ \textcolor{keywordflow}{default}:}
\DoxyCodeLine{00084\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eae974abf255ac5507a0c8163d0ebf9bcb}{eSRUtils\_48kRangeCoarse}}:}
\DoxyCodeLine{00085\ \ \ \ \ \ \ \ \ \ \ \ \ aGrossRateIndex\ =\ 0;}
\DoxyCodeLine{00086\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00087\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3ea376e9c46e970aa93e789445670b1d45f}{eSRUtils\_96kRangeCoarse}}:}
\DoxyCodeLine{00088\ \ \ \ \ \ \ \ \ \ \ \ \ aGrossRateIndex\ =\ 1;}
\DoxyCodeLine{00089\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00090\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{case}\ \mbox{\hyperlink{a00872_a65f189058b3204334c2c13d368d8ce3eadc3653ea09f8a83c8222afc5a386e28f}{eSRUtils\_192kRangeCoarse}}:}
\DoxyCodeLine{00091\ \ \ \ \ \ \ \ \ \ \ \ \ aGrossRateIndex\ =\ 2;}
\DoxyCodeLine{00092\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00093\ \textcolor{comment}{//\ \ \ \ \ \ default:}}
\DoxyCodeLine{00094\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ throw\ std::runtime\_error\ ("{}unrecognized\ sample\ rate"{});}}
\DoxyCodeLine{00095\ \ \ \ \ \}}
\DoxyCodeLine{00096\ }
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{keywordflow}{return}\ aGrossRateIndex;}
\DoxyCodeLine{00098\ \}}

\end{DoxyCode}
