00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SegmentSMSHarmonizer_
00024 #define _SegmentSMSHarmonizer_
00025
00026 #include "SMSPitchShift.hxx"
00027 #include "SpectrumAdder2.hxx"
00028 #include "FrameTransformation.hxx"
00029
00030
00031
00032
00033
00034 namespace CLAM{
00035
00036
00037 class SegmentSMSHarmonizer: public FrameTransformation
00038 {
00039
00043 const char *GetClassName() const {return "SegmentSMSHarmonizer";}
00044
00045 InControl mIndexCtl;
00046 InControlTmpl<SegmentSMSHarmonizer> mUpdateBPFCtl;
00047 InControl mTransCtl;
00051 InControlTmpl<SegmentSMSHarmonizer> mIgnoreResidualCtl;
00052 public:
00053
00054 int UpdateBPF(TControlData value)
00055 {
00056 CLAM::BPF& bpf= mConfig.GetBPF();
00057
00058 if(bpf.Size()==0)
00059 {
00060 InitBPF();
00061 }
00062
00063 bpf.SetValue((int)mIndexCtl.GetLastValue(), mTransCtl.GetLastValue());
00064 return 0;
00065 }
00066 int IgnoreResidual(TControlData value)
00067 {
00068 return mPitchShift.mIgnoreResidual.DoControl(value);
00069 }
00070 public:
00072 SegmentSMSHarmonizer():
00073 mIndexCtl("Index", this),
00074 mTransCtl("Transposition",this),
00075 mIgnoreResidualCtl("IgnoreResidual",this, &SegmentSMSHarmonizer::IgnoreResidual, true),
00076 mUpdateBPFCtl("UpdateBPF", this, &SegmentSMSHarmonizer::UpdateBPF, true)
00077 {
00078 Configure(FrameTransformationConfig());
00079 mTmpFrame.AddAll();
00080 mTmpFrame.UpdateData();
00081 mTmpFund.AddElem();
00082 }
00083
00084 bool ConcreteConfigure(const ProcessingConfig& c)
00085 {
00086 CopyAsConcreteConfig( mConfig, c );
00087 InitBPF();
00088 mPitchShift.Configure(FrameTransformationConfig());
00089
00090 mIgnoreResidualCtl.DoControl(1.);
00091 return true;
00092 }
00093
00095 ~SegmentSMSHarmonizer()
00096 {}
00097
00098 bool Do()
00099 {
00100 CLAM_ASSERT(false, "Do with ports not implemented");
00101 return false;
00102 }
00103
00104 bool Do(const Frame& in, Frame& out);
00105 private:
00106 SMSPitchShift mPitchShift;
00107 SpectrumAdder2 mSpectrumAdder;
00108 void AddFrame(const Frame& in1, const Frame& in2, Frame& out);
00109 void Gain(Frame& inputFrame, TData gain);
00110
00111 Fundamental mTmpFund;
00112 Frame mTmpFrame;
00113
00114 void InitBPF()
00115 {
00116 if (!mConfig.HasBPF())
00117 {
00118 mConfig.AddBPF();
00119 mConfig.UpdateData();
00120 }
00121 if(mConfig.GetBPF().Size()==0)
00122 {
00123 BPF& bpf=mConfig.GetBPF();
00124 bpf.Resize(10);
00125 bpf.SetSize(10);
00126 int i;
00127
00128 for (i=0; i< 10; i++)
00129 {
00130 bpf.SetValue(i,1);
00131 bpf.SetXValue(i,(i-5)*6);
00132 }
00133 }
00134 }
00135
00136
00137 };
00138 };
00139
00140 #endif // _SegmentSMSHarmonizer_
00141