00001 /* 00002 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 00023 #ifndef _SEGMENTSMSMORPH_ 00024 #define _SEGMENTSMSMORPH_ 00025 00026 #include "SegmentTransformation.hxx" 00027 #include "SegmentSMSMorphConfig.hxx" 00028 #include "SDIFIn.hxx" 00029 #include "FrameInterpolator.hxx" 00030 00031 namespace CLAM{ 00032 00033 00034 00037 class SegmentSMSMorph: public SegmentTransformation 00038 { 00039 00040 typedef InControlTmpl<SegmentSMSMorph> SegmentSMSMorphCtrl; 00041 00042 public: 00044 SegmentSMSMorph(); 00048 SegmentSMSMorph(const SegmentSMSMorphConfig &c); 00049 00053 const char *GetClassName() const {return "SegmentSMSMorph";} 00054 00055 const ProcessingConfig& GetConfig() const 00056 { 00057 return mConfig; 00058 } 00059 00060 bool ConcreteConfigure(const ProcessingConfig& c); 00061 bool ConcreteStart(); 00062 00064 ~SegmentSMSMorph() 00065 {} 00066 00067 00068 bool Do(const Segment& in1, Segment& out); 00069 bool Do(const Segment& in1,Segment& in2, Segment& out); 00070 bool Do(const Frame& in1, Frame& out); 00071 bool Do() 00072 { 00073 CLAM_ASSERT(false, "Do with ports not implemented"); 00074 return false; 00075 } 00076 00077 virtual bool UpdateControlValueFromBPF(TData pos); 00078 00079 void SetSegmentToMorph(Segment&segmentToMorph); 00080 00081 bool mUseGlobalFactor; 00082 SegmentSMSMorphCtrl mHybBPF; 00083 00084 bool mUseSynchronizeTime; 00085 SegmentSMSMorphCtrl mSynchronizeTime; 00086 00087 bool mUseSinAmp; 00088 SegmentSMSMorphCtrl mHybSinAmp; 00089 00090 bool mUseSinSpectralShape; 00091 SegmentSMSMorphCtrl mHybSinSpectralShape; 00092 SegmentSMSMorphCtrl mHybSinShapeW1; 00093 SegmentSMSMorphCtrl mHybSinShapeW2; 00094 00095 bool mUsePitch; 00096 SegmentSMSMorphCtrl mHybPitch; 00097 00098 bool mUseSinFreq; 00099 SegmentSMSMorphCtrl mHybSinFreq; 00100 00101 bool mUseResAmp; 00102 SegmentSMSMorphCtrl mHybResAmp; 00103 00104 bool mUseResSpectralShape; 00105 SegmentSMSMorphCtrl mHybResSpectralShape; 00106 SegmentSMSMorphCtrl mHybResShapeW1; 00107 SegmentSMSMorphCtrl mHybResShapeW2; 00108 00109 protected: 00110 00111 void UpdateFrameInterpolatorFactors(bool useFrameFactor); 00112 bool FindInterpolatedFrameFromSegment2Morph(Frame& interpolatedFrame); 00113 void UpdateSpectralShape(const BPF& weightBPF1, const BPF& weightBPF2, TData interpFactor, Spectrum& spectralShape); 00114 void InitializeFactorsToUse(); 00115 00116 bool LoadSDIF( std::string fileName, Segment& segment ); 00117 00118 SDIFIn mSDIFReader; 00119 SegmentSMSMorphConfig mConfig; 00120 00121 00125 Segment* mpInput2; 00126 00127 bool mHarmSpectralShapeMorph; 00128 bool mHaveInternalSegment; 00129 00130 Segment mSegment; 00131 00132 Spectrum mSpectralShape; 00133 Spectrum mResSpectralShape; 00134 00135 00138 FrameInterpolator mPO_FrameInterpolator; 00139 }; 00140 };//namespace CLAM 00141 00142 #endif // _SegmentSMSMorph_ 00143