\hypertarget{a00506_source}{}\doxysection{AAX\+\_\+\+CDecibel\+Display\+Delegate\+Decorator.\+h}
\label{a00506_source}\index{AAX\_CDecibelDisplayDelegateDecorator.h@{AAX\_CDecibelDisplayDelegateDecorator.h}}
\mbox{\hyperlink{a00506}{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\ 2013-\/2017,\ 2019,\ 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{00019\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00020\ }
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00022\ \textcolor{preprocessor}{\#ifndef\ AAX\_CDECIBELDISPLAYDELEGATEDECORATOR\_H}}
\DoxyCodeLine{00023\ \textcolor{preprocessor}{\#define\ AAX\_CDECIBELDISPLAYDELEGATEDECORATOR\_H}}
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00025\ }
\DoxyCodeLine{00026\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00539}{AAX\_IDisplayDelegateDecorator.h}}"{}}}
\DoxyCodeLine{00027\ \textcolor{preprocessor}{\#include\ <cmath>}}
\DoxyCodeLine{00028\ }
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00052\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00053\ \textcolor{keyword}{class\ }\mbox{\hyperlink{a01825}{AAX\_CDecibelDisplayDelegateDecorator}}\ :\ \textcolor{keyword}{public}\ \mbox{\hyperlink{a02225}{AAX\_IDisplayDelegateDecorator}}<T>}
\DoxyCodeLine{00054\ \{}
\DoxyCodeLine{00055\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00056\ \ \ \ \ \mbox{\hyperlink{a01825}{AAX\_CDecibelDisplayDelegateDecorator}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{a02221}{AAX\_IDisplayDelegate<T>}}\&\ displayDelegate);}
\DoxyCodeLine{00057\ \ \ \ \ }
\DoxyCodeLine{00058\ \ \ \ \ \textcolor{comment}{//Virtual\ Overrides}}
\DoxyCodeLine{00059\ \ \ \ \ \mbox{\hyperlink{a01825}{AAX\_CDecibelDisplayDelegateDecorator<T>}}*\ \mbox{\hyperlink{a01825_a2abd5f4d5a8d6db7db73fadfe8a2aa04}{Clone}}()\ \textcolor{keyword}{const}\ \mbox{\hyperlink{a00533_ac2f24a5172689ae684344abdcce55463}{AAX\_OVERRIDE}};}
\DoxyCodeLine{00060\ \ \ \ \ \textcolor{keywordtype}{bool}\ \ \ \ \ \ \ \ \mbox{\hyperlink{a01825_a147cb1d0b62b0a62c6e3bb98daf80027}{ValueToString}}(T\ value,\ \mbox{\hyperlink{a01933}{AAX\_CString}}*\ valueString)\ \textcolor{keyword}{const}\ \mbox{\hyperlink{a00533_ac2f24a5172689ae684344abdcce55463}{AAX\_OVERRIDE}};}
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{keywordtype}{bool}\ \ \ \ \ \ \ \ \mbox{\hyperlink{a01825_a147cb1d0b62b0a62c6e3bb98daf80027}{ValueToString}}(T\ value,\ int32\_t\ maxNumChars,\ \mbox{\hyperlink{a01933}{AAX\_CString}}*\ valueString)\ \textcolor{keyword}{const}\ \mbox{\hyperlink{a00533_ac2f24a5172689ae684344abdcce55463}{AAX\_OVERRIDE}};}
\DoxyCodeLine{00062\ \ \ \ \ \textcolor{keywordtype}{bool}\ \ \ \ \ \ \ \ \mbox{\hyperlink{a01825_a7f4645d7e464d63ef22e93c4a99f3f09}{StringToValue}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{a01933}{AAX\_CString}}\&\ valueString,\ T*\ value)\ \textcolor{keyword}{const}\ \mbox{\hyperlink{a00533_ac2f24a5172689ae684344abdcce55463}{AAX\_OVERRIDE}};}
\DoxyCodeLine{00063\ \};}
\DoxyCodeLine{00064\ }
\DoxyCodeLine{00065\ }
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00067\ }
\DoxyCodeLine{00068\ }
\DoxyCodeLine{00069\ }
\DoxyCodeLine{00070\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00071\ \mbox{\hyperlink{a01825_aac7fbdbd0ce453aac8fa78cc4d1cef19}{AAX\_CDecibelDisplayDelegateDecorator<T>::AAX\_CDecibelDisplayDelegateDecorator}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{a02221}{AAX\_IDisplayDelegate<T>}}\&\ displayDelegate)\ \ :}
\DoxyCodeLine{00072\ \ \ \ \ \mbox{\hyperlink{a02225}{AAX\_IDisplayDelegateDecorator}}<T>(displayDelegate)}
\DoxyCodeLine{00073\ \{}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \}}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00077\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00078\ \mbox{\hyperlink{a01825}{AAX\_CDecibelDisplayDelegateDecorator<T>}}*\ \mbox{\hyperlink{a01825_a2abd5f4d5a8d6db7db73fadfe8a2aa04}{AAX\_CDecibelDisplayDelegateDecorator<T>::Clone}}()\textcolor{keyword}{\ const}}
\DoxyCodeLine{00079\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00080\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{new}\ \mbox{\hyperlink{a01825}{AAX\_CDecibelDisplayDelegateDecorator}}(*\textcolor{keyword}{this});}
\DoxyCodeLine{00081\ \}}
\DoxyCodeLine{00082\ }
\DoxyCodeLine{00083\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00084\ \textcolor{keywordtype}{bool}\ \ \ \ \mbox{\hyperlink{a01825_a147cb1d0b62b0a62c6e3bb98daf80027}{AAX\_CDecibelDisplayDelegateDecorator<T>::ValueToString}}(T\ value,\ \mbox{\hyperlink{a01933}{AAX\_CString}}*\ valueString)\textcolor{keyword}{\ const\ }}
\DoxyCodeLine{00085\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00086\ \ \ \ \ \textcolor{keywordtype}{bool}\ succeeded\ =\ \textcolor{keyword}{false};}
\DoxyCodeLine{00087\ \ \ \ \ \textcolor{keywordflow}{if}\ (value\ <=\ 0)}
\DoxyCodeLine{00088\ \ \ \ \ \{}
\DoxyCodeLine{00089\ \ \ \ \ \ \ \ \ \textcolor{comment}{//*valueString\ =\ AAX\_CString("{}-\/-\/-\/\ dB"{});}}
\DoxyCodeLine{00090\ \ \ \ \ \ \ \ \ *valueString\ =\ \mbox{\hyperlink{a01933}{AAX\_CString}}(\textcolor{stringliteral}{"{}-\/INF\ "{}});}
\DoxyCodeLine{00091\ \ \ \ \ \ \ \ \ succeeded\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00092\ \ \ \ \ \}}
\DoxyCodeLine{00093\ \ \ \ \ \textcolor{keywordflow}{else}\ }
\DoxyCodeLine{00094\ \ \ \ \ \{}
\DoxyCodeLine{00095\ \ \ \ \ \ \ \ \ value\ =\ (T)(20.0*log10(value));}
\DoxyCodeLine{00096\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\ value\ >\ -\/0.01f\ \&\&\ value\ <\ 0.0f)\ \textcolor{comment}{//To\ prevent\ minus\ for\ 0.0\ value\ in\ automation\ turned\ on}}
\DoxyCodeLine{00097\ \ \ \ \ \ \ \ \ \ \ \ \ value\ =\ 0.0f;}
\DoxyCodeLine{00098\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00099\ \ \ \ \ \ \ \ \ succeeded\ =\ \mbox{\hyperlink{a02225_ada5780cfa332ac7946bf95aa65ae96f5}{AAX\_IDisplayDelegateDecorator<T>::ValueToString}}(value,\ valueString);\ \ \ \ \ }
\DoxyCodeLine{00100\ \ \ \ \ \}}
\DoxyCodeLine{00101\ \ \ \ \ }
\DoxyCodeLine{00102\ \ \ \ \ *valueString\ +=\ \mbox{\hyperlink{a01933}{AAX\_CString}}(\textcolor{stringliteral}{"{}dB"{}});}
\DoxyCodeLine{00103\ \ \ \ \ \textcolor{keywordflow}{return}\ succeeded;}
\DoxyCodeLine{00104\ \}}
\DoxyCodeLine{00105\ }
\DoxyCodeLine{00106\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00107\ \textcolor{keywordtype}{bool}\ \ \ \ \mbox{\hyperlink{a01825_a147cb1d0b62b0a62c6e3bb98daf80027}{AAX\_CDecibelDisplayDelegateDecorator<T>::ValueToString}}(T\ value,\ int32\_t\ maxNumChars,\ \mbox{\hyperlink{a01933}{AAX\_CString}}*\ valueString)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00108\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00109\ \ \ \ \ \textcolor{keywordflow}{if}\ (value\ <=\ 0)}
\DoxyCodeLine{00110\ \ \ \ \ \{}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ *valueString\ =\ \mbox{\hyperlink{a01933}{AAX\_CString}}(\textcolor{stringliteral}{"{}-\/INF"{}});}
\DoxyCodeLine{00112\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (maxNumChars\ >=\ 7)}
\DoxyCodeLine{00113\ \ \ \ \ \ \ \ \ \ \ \ \ valueString-\/>\mbox{\hyperlink{a01933_ac3aa81a641264098a440a4857be62091}{Append}}(\textcolor{stringliteral}{"{}\ dB"{}});\ \ \ \textcolor{comment}{//<DMT>\ Add\ a\ space\ for\ longer\ strings\ and\ dB}}
\DoxyCodeLine{00114\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00115\ \ \ \ \ \}}
\DoxyCodeLine{00116\ }
\DoxyCodeLine{00117\ \ \ \ \ value\ =\ (T)(20.0*log10(value));}
\DoxyCodeLine{00118\ \ \ \ \ \textcolor{keywordflow}{if}\ (\ value\ >\ -\/0.01f\ \&\&\ value\ <\ 0.0f)\ \textcolor{comment}{//To\ prevent\ minus\ for\ 0.0\ value\ in\ automation\ turned\ on}}
\DoxyCodeLine{00119\ \ \ \ \ \ \ \ \ value\ =\ 0.0f;}
\DoxyCodeLine{00120\ \ \ \ \ \textcolor{keywordtype}{bool}\ succeeded\ =\ \mbox{\hyperlink{a02225_ada5780cfa332ac7946bf95aa65ae96f5}{AAX\_IDisplayDelegateDecorator<T>::ValueToString}}(value,\ maxNumChars,\ valueString);}
\DoxyCodeLine{00121\ \ \ \ \ }
\DoxyCodeLine{00122\ \ \ \ \ }
\DoxyCodeLine{00123\ \ \ \ \ \textcolor{comment}{//<DMT>\ Check\ current\ string\ length\ and\ see\ if\ there\ is\ room\ to\ add\ units.\ \ I\ believe\ these\ units\ are\ usually\ less\ important\ than\ precision\ on\ control\ surfaces.}}
\DoxyCodeLine{00124\ \ \ \ \ uint32\_t\ strlen\ =\ valueString-\/>\mbox{\hyperlink{a01933_a34ccfa250b53a721417f32d4a74bfed6}{Length}}();}
\DoxyCodeLine{00125\ \ \ \ \ \textcolor{keyword}{const}\ uint32\_t\ maxNumCharsUnsigned\ =\ (0\ <=\ maxNumChars)\ ?\ \textcolor{keyword}{static\_cast<}uint32\_t\textcolor{keyword}{>}(maxNumChars)\ :\ 0;}
\DoxyCodeLine{00126\ \ \ \ \ \textcolor{keywordflow}{if}\ (maxNumCharsUnsigned\ >=\ (strlen\ +\ 2))\ \ \ \ \textcolor{comment}{//length\ of\ string\ plus\ 2\ for\ the\ "{}dB"{}}}
\DoxyCodeLine{00127\ \ \ \ \ \ \ \ \ *valueString\ +=\ \mbox{\hyperlink{a01933}{AAX\_CString}}(\textcolor{stringliteral}{"{}dB"{}});}
\DoxyCodeLine{00128\ \ \ \ \ \textcolor{keywordflow}{return}\ succeeded;}
\DoxyCodeLine{00129\ \}}
\DoxyCodeLine{00130\ }
\DoxyCodeLine{00131\ }
\DoxyCodeLine{00132\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00133\ \textcolor{keywordtype}{bool}\ \ \ \ \mbox{\hyperlink{a01825_a7f4645d7e464d63ef22e93c4a99f3f09}{AAX\_CDecibelDisplayDelegateDecorator<T>::StringToValue}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{a01933}{AAX\_CString}}\&\ valueString,\ T*\ value)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00134\ \textcolor{keyword}{}\{\ \ \ \ \ \ \ }
\DoxyCodeLine{00135\ \ \ \ \ \textcolor{comment}{//Just\ call\ through\ if\ there\ is\ obviously\ no\ unit\ string.}}
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{keywordflow}{if}\ (valueString.\mbox{\hyperlink{a01933_a34ccfa250b53a721417f32d4a74bfed6}{Length}}()\ <=\ 2)}
\DoxyCodeLine{00137\ \ \ \ \ \{}
\DoxyCodeLine{00138\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ success\ =\ \mbox{\hyperlink{a02225_a18d19293f3eca619cb5bb7f1ffde1a8d}{AAX\_IDisplayDelegateDecorator<T>::StringToValue}}(valueString,\ value);}
\DoxyCodeLine{00139\ \ \ \ \ \ \ \ \ *value\ =\ (T)pow((T)10.0,\ (*value\ /\ (T)20.0));}
\DoxyCodeLine{00140\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ success;}
\DoxyCodeLine{00141\ \ \ \ \ \}}
\DoxyCodeLine{00142\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00143\ \ \ \ \ \textcolor{comment}{//Just\ call\ through\ if\ the\ end\ of\ this\ string\ does\ not\ match\ the\ unit\ string.\ \ \ }}
\DoxyCodeLine{00144\ \ \ \ \ \mbox{\hyperlink{a01933}{AAX\_CString}}\ unitSubString;}
\DoxyCodeLine{00145\ \ \ \ \ valueString.\mbox{\hyperlink{a01933_a35132df5b9f73bc2ddbfd673f4a5d22a}{SubString}}(valueString.\mbox{\hyperlink{a01933_a34ccfa250b53a721417f32d4a74bfed6}{Length}}()\ -\/\ 2,\ 2,\ \&unitSubString);}
\DoxyCodeLine{00146\ \ \ \ \ \textcolor{keywordflow}{if}\ (unitSubString\ !=\ \mbox{\hyperlink{a01933}{AAX\_CString}}(\textcolor{stringliteral}{"{}dB"{}}))}
\DoxyCodeLine{00147\ \ \ \ \ \{}
\DoxyCodeLine{00148\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ success\ =\ \mbox{\hyperlink{a02225_a18d19293f3eca619cb5bb7f1ffde1a8d}{AAX\_IDisplayDelegateDecorator<T>::StringToValue}}(valueString,\ value);}
\DoxyCodeLine{00149\ \ \ \ \ \ \ \ \ *value\ =\ (T)pow((T)10.0,\ *value\ /\ (T)20.0);}
\DoxyCodeLine{00150\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ success;}
\DoxyCodeLine{00151\ \ \ \ \ \}}
\DoxyCodeLine{00152\ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00153\ \ \ \ \ \textcolor{comment}{//Call\ through\ with\ the\ stripped\ down\ value\ string.\ \ }}
\DoxyCodeLine{00154\ \ \ \ \ \mbox{\hyperlink{a01933}{AAX\_CString}}\ valueSubString;}
\DoxyCodeLine{00155\ \ \ \ \ valueString.\mbox{\hyperlink{a01933_a35132df5b9f73bc2ddbfd673f4a5d22a}{SubString}}(0,\ valueString.\mbox{\hyperlink{a01933_a34ccfa250b53a721417f32d4a74bfed6}{Length}}()\ -\/\ 2,\ \&valueSubString);}
\DoxyCodeLine{00156\ \ \ \ \ \textcolor{keywordtype}{bool}\ success\ =\ \mbox{\hyperlink{a02225_a18d19293f3eca619cb5bb7f1ffde1a8d}{AAX\_IDisplayDelegateDecorator<T>::StringToValue}}(valueSubString,\ value);}
\DoxyCodeLine{00157\ \ \ \ \ *value\ =\ (T)pow((T)10.0,\ *value\ /\ (T)20.0);}
\DoxyCodeLine{00158\ \ \ \ \ \textcolor{keywordflow}{return}\ success;}
\DoxyCodeLine{00159\ \}}
\DoxyCodeLine{00160\ }
\DoxyCodeLine{00161\ }
\DoxyCodeLine{00162\ }
\DoxyCodeLine{00163\ }
\DoxyCodeLine{00164\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//AAX\_CDECIBELDISPLAYDELEGATEDECORATOR\_H}}

\end{DoxyCode}
