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 public: 00042 SegmentSMSMorph(); 00046 SegmentSMSMorph(const SegmentSMSMorphConfig &c); 00047 00051 const char *GetClassName() const {return "SegmentSMSMorph";} 00052 00053 const ProcessingConfig& GetConfig() const 00054 { 00055 return mConfig; 00056 } 00057 00058 bool ConcreteConfigure(const ProcessingConfig& c); 00059 bool ConcreteStart(); 00060 00062 ~SegmentSMSMorph() 00063 {} 00064 00065 00066 bool Do(const Segment& in1, Segment& out); 00067 bool Do(const Segment& in1,Segment& in2, Segment& out); 00068 bool Do(const Frame& in1, Frame& out); 00069 bool Do() 00070 { 00071 CLAM_ASSERT(false, "Do with ports not implemented"); 00072 return false; 00073 } 00074 00075 virtual bool UpdateControlValueFromBPF(TData pos); 00076 00077 void SetSegmentToMorph(Segment&segmentToMorph); 00078 00079 bool mUseGlobalFactor; 00080 FloatInControl mHybBPF; 00081 00082 bool mUseSynchronizeTime; 00083 FloatInControl mSynchronizeTime; 00084 00085 bool mUseSinAmp; 00086 FloatInControl mHybSinAmp; 00087 00088 bool mUseSinSpectralShape; 00089 FloatInControl mHybSinSpectralShape; 00090 FloatInControl mHybSinShapeW1; 00091 FloatInControl mHybSinShapeW2; 00092 00093 bool mUsePitch; 00094 FloatInControl mHybPitch; 00095 00096 bool mUseSinFreq; 00097 FloatInControl mHybSinFreq; 00098 00099 bool mUseResAmp; 00100 FloatInControl mHybResAmp; 00101 00102 bool mUseResSpectralShape; 00103 FloatInControl mHybResSpectralShape; 00104 FloatInControl mHybResShapeW1; 00105 FloatInControl mHybResShapeW2; 00106 00107 protected: 00108 00109 void UpdateFrameInterpolatorFactors(bool useFrameFactor); 00110 bool FindInterpolatedFrameFromSegment2Morph(Frame& interpolatedFrame); 00111 void UpdateSpectralShape(const BPF& weightBPF1, const BPF& weightBPF2, TData interpFactor, Spectrum& spectralShape); 00112 void InitializeFactorsToUse(); 00113 00114 bool LoadSDIF( std::string fileName, Segment& segment ); 00115 00116 SDIFIn mSDIFReader; 00117 SegmentSMSMorphConfig mConfig; 00118 00119 00123 Segment* mpInput2; 00124 00125 bool mHarmSpectralShapeMorph; 00126 bool mHaveInternalSegment; 00127 00128 Segment mSegment; 00129 00130 Spectrum mSpectralShape; 00131 Spectrum mResSpectralShape; 00132 00133 00136 FrameInterpolator mPO_FrameInterpolator; 00137 }; 00138 };//namespace CLAM 00139 00140 #endif // _SegmentSMSMorph_ 00141