\hypertarget{a00515_source}{}\doxysection{AAX\+\_\+\+CDecibel\+Display\+Delegate\+Decorator.\+h}
\label{a00515_source}\index{AAX\_CDecibelDisplayDelegateDecorator.h@{AAX\_CDecibelDisplayDelegateDecorator.h}}
\mbox{\hyperlink{a00515}{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-\/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{00032\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00034\ }
\DoxyCodeLine{00035\ \textcolor{preprocessor}{\#ifndef\ AAX\_CDECIBELDISPLAYDELEGATEDECORATOR\_H}}
\DoxyCodeLine{00036\ \textcolor{preprocessor}{\#define\ AAX\_CDECIBELDISPLAYDELEGATEDECORATOR\_H}}
\DoxyCodeLine{00037\ }
\DoxyCodeLine{00038\ }
\DoxyCodeLine{00039\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00548}{AAX\_IDisplayDelegateDecorator.h}}"{}}}
\DoxyCodeLine{00040\ \textcolor{preprocessor}{\#include\ <cmath>}}
\DoxyCodeLine{00041\ }
\DoxyCodeLine{00042\ }
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00065\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00066\ \textcolor{keyword}{class\ }\mbox{\hyperlink{a01838}{AAX\_CDecibelDisplayDelegateDecorator}}\ :\ \textcolor{keyword}{public}\ \mbox{\hyperlink{a02246}{AAX\_IDisplayDelegateDecorator}}<T>}
\DoxyCodeLine{00067\ \{}
\DoxyCodeLine{00068\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00069\ \ \ \ \ \mbox{\hyperlink{a01838}{AAX\_CDecibelDisplayDelegateDecorator}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{a02242}{AAX\_IDisplayDelegate<T>}}\&\ displayDelegate);}
\DoxyCodeLine{00070\ \ \ \ \ }
\DoxyCodeLine{00071\ \ \ \ \ \textcolor{comment}{//Virtual\ Overrides}}
\DoxyCodeLine{00072\ \ \ \ \ \mbox{\hyperlink{a01838}{AAX\_CDecibelDisplayDelegateDecorator<T>}}*\ \mbox{\hyperlink{a01838_a2abd5f4d5a8d6db7db73fadfe8a2aa04}{Clone}}()\ \textcolor{keyword}{const}\ \mbox{\hyperlink{a00542_ac2f24a5172689ae684344abdcce55463}{AAX\_OVERRIDE}};}
\DoxyCodeLine{00073\ \ \ \ \ \textcolor{keywordtype}{bool}\ \ \ \ \ \ \ \ \mbox{\hyperlink{a01838_a147cb1d0b62b0a62c6e3bb98daf80027}{ValueToString}}(T\ value,\ \mbox{\hyperlink{a01946}{AAX\_CString}}*\ valueString)\ \textcolor{keyword}{const}\ \mbox{\hyperlink{a00542_ac2f24a5172689ae684344abdcce55463}{AAX\_OVERRIDE}};}
\DoxyCodeLine{00074\ \ \ \ \ \textcolor{keywordtype}{bool}\ \ \ \ \ \ \ \ \mbox{\hyperlink{a01838_a147cb1d0b62b0a62c6e3bb98daf80027}{ValueToString}}(T\ value,\ int32\_t\ maxNumChars,\ \mbox{\hyperlink{a01946}{AAX\_CString}}*\ valueString)\ \textcolor{keyword}{const}\ \mbox{\hyperlink{a00542_ac2f24a5172689ae684344abdcce55463}{AAX\_OVERRIDE}};}
\DoxyCodeLine{00075\ \ \ \ \ \textcolor{keywordtype}{bool}\ \ \ \ \ \ \ \ \mbox{\hyperlink{a01838_a7f4645d7e464d63ef22e93c4a99f3f09}{StringToValue}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{a01946}{AAX\_CString}}\&\ valueString,\ T*\ value)\ \textcolor{keyword}{const}\ \mbox{\hyperlink{a00542_ac2f24a5172689ae684344abdcce55463}{AAX\_OVERRIDE}};}
\DoxyCodeLine{00076\ \};}
\DoxyCodeLine{00077\ }
\DoxyCodeLine{00078\ }
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ }
\DoxyCodeLine{00081\ }
\DoxyCodeLine{00082\ }
\DoxyCodeLine{00083\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00084\ \mbox{\hyperlink{a01838_aac7fbdbd0ce453aac8fa78cc4d1cef19}{AAX\_CDecibelDisplayDelegateDecorator<T>::AAX\_CDecibelDisplayDelegateDecorator}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{a02242}{AAX\_IDisplayDelegate<T>}}\&\ displayDelegate)\ \ :}
\DoxyCodeLine{00085\ \ \ \ \ \mbox{\hyperlink{a02246}{AAX\_IDisplayDelegateDecorator}}<T>(displayDelegate)}
\DoxyCodeLine{00086\ \{}
\DoxyCodeLine{00087\ }
\DoxyCodeLine{00088\ \}}
\DoxyCodeLine{00089\ }
\DoxyCodeLine{00090\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00091\ \mbox{\hyperlink{a01838}{AAX\_CDecibelDisplayDelegateDecorator<T>}}*\ \mbox{\hyperlink{a01838_a2abd5f4d5a8d6db7db73fadfe8a2aa04}{AAX\_CDecibelDisplayDelegateDecorator<T>::Clone}}()\textcolor{keyword}{\ const}}
\DoxyCodeLine{00092\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00093\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{new}\ \mbox{\hyperlink{a01838}{AAX\_CDecibelDisplayDelegateDecorator}}(*\textcolor{keyword}{this});}
\DoxyCodeLine{00094\ \}}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00096\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00097\ \textcolor{keywordtype}{bool}\ \ \ \ \mbox{\hyperlink{a01838_a147cb1d0b62b0a62c6e3bb98daf80027}{AAX\_CDecibelDisplayDelegateDecorator<T>::ValueToString}}(T\ value,\ \mbox{\hyperlink{a01946}{AAX\_CString}}*\ valueString)\textcolor{keyword}{\ const\ }}
\DoxyCodeLine{00098\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00099\ \ \ \ \ \textcolor{keywordtype}{bool}\ succeeded\ =\ \textcolor{keyword}{false};}
\DoxyCodeLine{00100\ \ \ \ \ \textcolor{keywordflow}{if}\ (value\ <=\ 0)}
\DoxyCodeLine{00101\ \ \ \ \ \{}
\DoxyCodeLine{00102\ \ \ \ \ \ \ \ \ \textcolor{comment}{//*valueString\ =\ AAX\_CString("{}-\/-\/-\/\ dB"{});}}
\DoxyCodeLine{00103\ \ \ \ \ \ \ \ \ *valueString\ =\ \mbox{\hyperlink{a01946}{AAX\_CString}}(\textcolor{stringliteral}{"{}-\/INF\ "{}});}
\DoxyCodeLine{00104\ \ \ \ \ \ \ \ \ succeeded\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00105\ \ \ \ \ \}}
\DoxyCodeLine{00106\ \ \ \ \ \textcolor{keywordflow}{else}\ }
\DoxyCodeLine{00107\ \ \ \ \ \{}
\DoxyCodeLine{00108\ \ \ \ \ \ \ \ \ value\ =\ (T)(20.0*log10(value));}
\DoxyCodeLine{00109\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\ value\ >\ -\/0.01f\ \&\&\ value\ <\ 0.0f)\ \textcolor{comment}{//To\ prevent\ minus\ for\ 0.0\ value\ in\ automation\ turned\ on}}
\DoxyCodeLine{00110\ \ \ \ \ \ \ \ \ \ \ \ \ value\ =\ 0.0f;}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00112\ \ \ \ \ \ \ \ \ succeeded\ =\ \mbox{\hyperlink{a02246_ada5780cfa332ac7946bf95aa65ae96f5}{AAX\_IDisplayDelegateDecorator<T>::ValueToString}}(value,\ valueString);\ \ \ \ \ }
\DoxyCodeLine{00113\ \ \ \ \ \}}
\DoxyCodeLine{00114\ \ \ \ \ }
\DoxyCodeLine{00115\ \ \ \ \ *valueString\ +=\ \mbox{\hyperlink{a01946}{AAX\_CString}}(\textcolor{stringliteral}{"{}dB"{}});}
\DoxyCodeLine{00116\ \ \ \ \ \textcolor{keywordflow}{return}\ succeeded;}
\DoxyCodeLine{00117\ \}}
\DoxyCodeLine{00118\ }
\DoxyCodeLine{00119\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00120\ \textcolor{keywordtype}{bool}\ \ \ \ \mbox{\hyperlink{a01838_a147cb1d0b62b0a62c6e3bb98daf80027}{AAX\_CDecibelDisplayDelegateDecorator<T>::ValueToString}}(T\ value,\ int32\_t\ maxNumChars,\ \mbox{\hyperlink{a01946}{AAX\_CString}}*\ valueString)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00121\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00122\ \ \ \ \ \textcolor{keywordflow}{if}\ (value\ <=\ 0)}
\DoxyCodeLine{00123\ \ \ \ \ \{}
\DoxyCodeLine{00124\ \ \ \ \ \ \ \ \ *valueString\ =\ \mbox{\hyperlink{a01946}{AAX\_CString}}(\textcolor{stringliteral}{"{}-\/INF"{}});}
\DoxyCodeLine{00125\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (maxNumChars\ >=\ 7)}
\DoxyCodeLine{00126\ \ \ \ \ \ \ \ \ \ \ \ \ valueString-\/>\mbox{\hyperlink{a01946_ac3aa81a641264098a440a4857be62091}{Append}}(\textcolor{stringliteral}{"{}\ dB"{}});\ \ \ \textcolor{comment}{//<DMT>\ Add\ a\ space\ for\ longer\ strings\ and\ dB}}
\DoxyCodeLine{00127\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00128\ \ \ \ \ \}}
\DoxyCodeLine{00129\ }
\DoxyCodeLine{00130\ \ \ \ \ value\ =\ (T)(20.0*log10(value));}
\DoxyCodeLine{00131\ \ \ \ \ \textcolor{keywordflow}{if}\ (\ value\ >\ -\/0.01f\ \&\&\ value\ <\ 0.0f)\ \textcolor{comment}{//To\ prevent\ minus\ for\ 0.0\ value\ in\ automation\ turned\ on}}
\DoxyCodeLine{00132\ \ \ \ \ \ \ \ \ value\ =\ 0.0f;}
\DoxyCodeLine{00133\ \ \ \ \ \textcolor{keywordtype}{bool}\ succeeded\ =\ \mbox{\hyperlink{a02246_ada5780cfa332ac7946bf95aa65ae96f5}{AAX\_IDisplayDelegateDecorator<T>::ValueToString}}(value,\ maxNumChars,\ valueString);}
\DoxyCodeLine{00134\ \ \ \ \ }
\DoxyCodeLine{00135\ \ \ \ \ }
\DoxyCodeLine{00136\ \ \ \ \ \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{00137\ \ \ \ \ uint32\_t\ strlen\ =\ valueString-\/>\mbox{\hyperlink{a01946_a34ccfa250b53a721417f32d4a74bfed6}{Length}}();}
\DoxyCodeLine{00138\ \ \ \ \ \textcolor{keyword}{const}\ uint32\_t\ maxNumCharsUnsigned\ =\ (0\ <=\ maxNumChars)\ ?\ \textcolor{keyword}{static\_cast<}uint32\_t\textcolor{keyword}{>}(maxNumChars)\ :\ 0;}
\DoxyCodeLine{00139\ \ \ \ \ \textcolor{keywordflow}{if}\ (maxNumCharsUnsigned\ >=\ (strlen\ +\ 2))\ \ \ \ \textcolor{comment}{//length\ of\ string\ plus\ 2\ for\ the\ "{}dB"{}}}
\DoxyCodeLine{00140\ \ \ \ \ \ \ \ \ *valueString\ +=\ \mbox{\hyperlink{a01946}{AAX\_CString}}(\textcolor{stringliteral}{"{}dB"{}});}
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{keywordflow}{return}\ succeeded;}
\DoxyCodeLine{00142\ \}}
\DoxyCodeLine{00143\ }
\DoxyCodeLine{00144\ }
\DoxyCodeLine{00145\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00146\ \textcolor{keywordtype}{bool}\ \ \ \ \mbox{\hyperlink{a01838_a7f4645d7e464d63ef22e93c4a99f3f09}{AAX\_CDecibelDisplayDelegateDecorator<T>::StringToValue}}(\textcolor{keyword}{const}\ \mbox{\hyperlink{a01946}{AAX\_CString}}\&\ valueString,\ T*\ value)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00147\ \textcolor{keyword}{}\{\ \ \ \ \ \ \ }
\DoxyCodeLine{00148\ \ \ \ \ \textcolor{comment}{//Just\ call\ through\ if\ there\ is\ obviously\ no\ unit\ string.}}
\DoxyCodeLine{00149\ \ \ \ \ \textcolor{keywordflow}{if}\ (valueString.\mbox{\hyperlink{a01946_a34ccfa250b53a721417f32d4a74bfed6}{Length}}()\ <=\ 2)}
\DoxyCodeLine{00150\ \ \ \ \ \{}
\DoxyCodeLine{00151\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ success\ =\ \mbox{\hyperlink{a02246_a18d19293f3eca619cb5bb7f1ffde1a8d}{AAX\_IDisplayDelegateDecorator<T>::StringToValue}}(valueString,\ value);}
\DoxyCodeLine{00152\ \ \ \ \ \ \ \ \ *value\ =\ (T)pow((T)10.0,\ (*value\ /\ (T)20.0));}
\DoxyCodeLine{00153\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ success;}
\DoxyCodeLine{00154\ \ \ \ \ \}}
\DoxyCodeLine{00155\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00156\ \ \ \ \ \textcolor{comment}{//Just\ call\ through\ if\ the\ end\ of\ this\ string\ does\ not\ match\ the\ unit\ string.\ \ \ }}
\DoxyCodeLine{00157\ \ \ \ \ \mbox{\hyperlink{a01946}{AAX\_CString}}\ unitSubString;}
\DoxyCodeLine{00158\ \ \ \ \ valueString.\mbox{\hyperlink{a01946_a35132df5b9f73bc2ddbfd673f4a5d22a}{SubString}}(valueString.\mbox{\hyperlink{a01946_a34ccfa250b53a721417f32d4a74bfed6}{Length}}()\ -\/\ 2,\ 2,\ \&unitSubString);}
\DoxyCodeLine{00159\ \ \ \ \ \textcolor{keywordflow}{if}\ (unitSubString\ !=\ \mbox{\hyperlink{a01946}{AAX\_CString}}(\textcolor{stringliteral}{"{}dB"{}}))}
\DoxyCodeLine{00160\ \ \ \ \ \{}
\DoxyCodeLine{00161\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ success\ =\ \mbox{\hyperlink{a02246_a18d19293f3eca619cb5bb7f1ffde1a8d}{AAX\_IDisplayDelegateDecorator<T>::StringToValue}}(valueString,\ value);}
\DoxyCodeLine{00162\ \ \ \ \ \ \ \ \ *value\ =\ (T)pow((T)10.0,\ *value\ /\ (T)20.0);}
\DoxyCodeLine{00163\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ success;}
\DoxyCodeLine{00164\ \ \ \ \ \}}
\DoxyCodeLine{00165\ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00166\ \ \ \ \ \textcolor{comment}{//Call\ through\ with\ the\ stripped\ down\ value\ string.\ \ }}
\DoxyCodeLine{00167\ \ \ \ \ \mbox{\hyperlink{a01946}{AAX\_CString}}\ valueSubString;}
\DoxyCodeLine{00168\ \ \ \ \ valueString.\mbox{\hyperlink{a01946_a35132df5b9f73bc2ddbfd673f4a5d22a}{SubString}}(0,\ valueString.\mbox{\hyperlink{a01946_a34ccfa250b53a721417f32d4a74bfed6}{Length}}()\ -\/\ 2,\ \&valueSubString);}
\DoxyCodeLine{00169\ \ \ \ \ \textcolor{keywordtype}{bool}\ success\ =\ \mbox{\hyperlink{a02246_a18d19293f3eca619cb5bb7f1ffde1a8d}{AAX\_IDisplayDelegateDecorator<T>::StringToValue}}(valueSubString,\ value);}
\DoxyCodeLine{00170\ \ \ \ \ *value\ =\ (T)pow((T)10.0,\ *value\ /\ (T)20.0);}
\DoxyCodeLine{00171\ \ \ \ \ \textcolor{keywordflow}{return}\ success;}
\DoxyCodeLine{00172\ \}}
\DoxyCodeLine{00173\ }
\DoxyCodeLine{00174\ }
\DoxyCodeLine{00175\ }
\DoxyCodeLine{00176\ }
\DoxyCodeLine{00177\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//AAX\_CDECIBELDISPLAYDELEGATEDECORATOR\_H}}

\end{DoxyCode}
