00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _SMSSineFilter_
00023 #define _SMSSineFilter_
00024
00025 #include "BPF.hxx"
00026 #include "InPort.hxx"
00027 #include "OutPort.hxx"
00028 #include "Frame.hxx"
00029 #include "SpectralPeakArray.hxx"
00030 #include "FrameTransformation.hxx"
00031 #include "FrameTransformationConfig.hxx"
00032 #include "Processing.hxx"
00033 #include "SegmentTransformationConfig.hxx"
00034
00035
00036 namespace CLAM
00037 {
00038
00039
00040
00041
00042
00043
00045
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 class SMSSineFilter: public FrameTransformation
00069 {
00070
00074 const char *GetClassName() const {return "SMSSineFilter";}
00075
00076 InPort<SpectralPeakArray> mInPeaks;
00077 OutPort<SpectralPeakArray> mOutPeaks;
00078
00079 InControl mIndexCtl;
00080 InControlTmpl<SMSSineFilter> mUpdateBPFCtl;
00081 InControl mGainCtl;
00082
00083 int UpdateBPF(TControlData value)
00084 {
00085 CLAM::BPF& bpf= mConfig.GetBPF();
00086
00087 if(bpf.Size()==0)
00088 {
00089 InitBPF();
00090 }
00091
00092 bpf.SetValue((int)mIndexCtl.GetLastValue(), mGainCtl.GetLastValue());
00093 return 0;
00094 }
00095
00096 public:
00098 SMSSineFilter()
00099 :
00100 mInPeaks("In SpectralPeaks", this),
00101 mOutPeaks("Out SpectralPeaks", this),
00102 mIndexCtl("Index", this),
00103 mGainCtl("Gain",this),
00104 mUpdateBPFCtl("UpdateBPF", this, &SMSSineFilter::UpdateBPF, true)
00105
00106 {
00107
00108
00109 mConfig.AddBPF();
00110 mConfig.UpdateData();
00111 Configure( mConfig );
00112 }
00116 SMSSineFilter(const FrameTransformationConfig& cfg )
00117 :
00118 mInPeaks("In SpectralPeaks", this),
00119 mOutPeaks("Out SpectralPeaks", this),
00120 mIndexCtl("Index", this),
00121 mGainCtl("Gain",this),
00122 mUpdateBPFCtl("UpdateBPF", this, &SMSSineFilter::UpdateBPF, true)
00123 {
00124 Configure( cfg );
00125 }
00126
00127 virtual bool ConcreteConfigure(const ProcessingConfig& cfg)
00128 {
00129 CopyAsConcreteConfig( mConfig, cfg );
00130 InitBPF();
00131 return true;
00132 }
00133
00134 const ProcessingConfig& GetConfig() const { return mConfig; }
00135
00137 ~SMSSineFilter()
00138 {}
00139
00140 bool Do(const Frame& in, Frame& out)
00141 {
00142 return Do( in.GetSpectralPeakArray(), out.GetSpectralPeakArray() );
00143 }
00144
00145 bool Do(const SpectralPeakArray& in, SpectralPeakArray& out);
00146
00147
00148 bool Do()
00149 {
00150 bool result = Do( mInPeaks.GetData(), mOutPeaks.GetData() );
00151 mInPeaks.Consume();
00152 mOutPeaks.Produce();
00153 return result;
00154 }
00155
00156 void InitBPF()
00157 {
00158 if (!mConfig.HasBPF())
00159 {
00160 mConfig.AddBPF();
00161 mConfig.UpdateData();
00162 }
00163 if(mConfig.GetBPF().Size()==0)
00164 {
00165 BPF& bpf=mConfig.GetBPF();
00166 bpf.Resize(500);
00167 bpf.SetSize(500);
00168 int i;
00169 for (i=0; i< 500; i++)
00170 {
00171 bpf.SetValue(i,0);
00172 }
00173 }
00174 }
00175
00176 };
00177 }
00178
00179 #endif // _SMSSineFilter_
00180