SpectralPeak.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00025
00026
00027
00028
00029
00030
00031
00033
00034
00035 #ifndef _SpectralPeak_
00036 #define _SpectralPeak_
00037
00038 #include <typeinfo>
00039
00040 #include "DynamicType.hxx"
00041 #include "Array.hxx"
00042 #include "DataTypes.hxx"
00043 #include "OSDefines.hxx"
00044 #include "Err.hxx"
00045 #include "ProcessingData.hxx"
00046 #include "GlobalEnums.hxx"
00047 #include "CLAM_Math.hxx"
00048
00049 namespace CLAM{
00050
00051
00052
00062 class SpectralPeak: public ProcessingData
00063 {
00064 public:
00065 DYNAMIC_TYPE_USING_INTERFACE (SpectralPeak, 6, ProcessingData);
00066 DYN_ATTRIBUTE (0, public, EScale, Scale);
00067 DYN_ATTRIBUTE (1, public, TData, Freq);
00068 DYN_ATTRIBUTE (2, public, TData, Mag);
00069 DYN_ATTRIBUTE (3, public, TData, BinPos);
00070 DYN_ATTRIBUTE (4, public, TData, Phase);
00071 DYN_ATTRIBUTE (5, public, int, BinWidth);
00072
00073
00074 protected:
00077 void DefaultInit();
00078
00079 public:
00080
00081
00086 TData operator|(const SpectralPeak& a) const
00087 {
00088 return (Abs(GetFreq()-a.GetFreq()));
00089 }
00097 friend SpectralPeak operator * (const SpectralPeak& peak,int factor)
00098 {
00099 SpectralPeak ret;
00100 ret.SetFreq(peak.GetFreq());
00101 ret.SetMag(peak.GetMag()*factor);
00102 ret.SetPhase(peak.GetPhase());
00103 ret.SetBinPos(peak.GetBinPos());
00104 ret.SetBinWidth(peak.GetBinWidth());
00105 ret.SetScale(peak.GetScale());
00106 return ret;
00107 }
00108
00109
00110 };
00111
00118 inline SpectralPeak Lin(SpectralPeak &inPeak,int scalingFactor)
00119 {
00120 if (inPeak.GetScale()!=EScale::eLinear){
00121 TData currMag = inPeak.GetMag();
00122 inPeak.SetMag(CLAM_pow(TData(10),TData(currMag/scalingFactor)));
00123 inPeak.SetScale(EScale::eLinear);
00124 }
00125 return inPeak;
00126 }
00127
00128 inline SpectralPeak Lin(SpectralPeak &inPeak)
00129 {
00130 if (inPeak.GetScale()!=EScale::eLinear){
00131 TData currMag = inPeak.GetMag();
00132 inPeak.SetMag(log2lin(currMag));
00133 inPeak.SetScale(EScale::eLinear);
00134 }
00135 return inPeak;
00136 }
00137
00138
00144 inline SpectralPeak DB(SpectralPeak& inPeak,int scalingFactor=20)
00145 {
00146 if (inPeak.GetScale()!=EScale::eLog){
00147 TData currMag = inPeak.GetMag();
00148 inPeak.SetMag(scalingFactor*CLAM_log10(currMag));
00149 inPeak.SetScale(EScale::eLog);
00150 }
00151 return inPeak;
00152 }
00153
00154 };
00155
00156 #endif
00157