SegmentTransformation.hxx

Go to the documentation of this file.
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 #ifndef _SegmentTransformation_
00023 #define _SegmentTransformation_
00024 
00025 
00026 #include "Processing.hxx"
00027 #include "ProcessingData.hxx"
00028 #include "InPort.hxx"
00029 #include "OutPort.hxx"
00030 #include "OutControl.hxx"
00031 #include "InControl.hxx"
00032 #include "InControlPublisher.hxx"
00033 #include "SpectralPeakArray.hxx"
00034 #include "Frame.hxx"
00035 #include "Segment.hxx"
00036 #include "SegmentTransformationConfig.hxx"
00037 
00038 #include "FrameTransformation.hxx"
00039 
00040 namespace CLAM {
00041 
00042         class SegmentTransformation: public Processing
00043         {
00044                 
00045                 FrameTransformation* mFrameTransformation;
00046 
00047         protected:
00048 //              FloatOutControl mSendAmount; //TODO privatize
00050                 SegmentTransformationConfig mConfig;
00056                 bool mUseTemporalBPF;
00060                 FloatInControl mOnCtrl;
00061                 
00062                 Segment* mInput;
00063                 Segment* mOutput;
00064         public:
00069                 InControlPublisher mAmountCtrl;
00070                 
00071 
00072         public:
00073                 void AttachIn( Segment& data ){ mInput = &data; }
00074                 void AttachOut( Segment& data ){ mOutput = &data; }
00075 
00076                 void WrapFrameTransformation( FrameTransformation*);
00077                 
00084                 virtual bool ConcreteConfigure(const ProcessingConfig& c);
00085 
00086                 const ProcessingConfig& GetConfig() const
00087                 {
00088                         return mConfig;
00089                 }
00090 
00092                 SegmentTransformation();
00093 
00097                 SegmentTransformation(const SegmentTransformationConfig& c);
00098                 
00099                 virtual ~SegmentTransformation();
00100 
00104                 virtual bool DoWithSegments(void)
00105                 {
00106                         return Do(*mInput, *mOutput);
00107                 }
00108 
00112                 virtual bool UpdateControlValueFromBPF(TData pos);
00113 
00115                 virtual bool IsLastFrame();
00116                 
00118                 bool ConcreteStart();
00119 
00120         protected:
00121 
00122 
00123                 virtual bool Do(const Frame& in,Frame& out) { return true; } 
00124                 bool Do() { return true; } 
00125                 const char* GetClassName() const { return "SegmentTransformation"; } 
00126 
00127 
00128                 void AddFramesToOutputIfInputIsLonger(int frameindex, const Segment& in, Segment& out)
00129                 {
00130                         if(frameindex==out.GetnFrames() && in.GetnFrames()>out.GetnFrames())
00131                                         out.AddFrame(out.GetFrame((TIndex)out.GetnFrames()-1));
00132                 }
00133                 
00141                 virtual bool Do(const Segment& in, Segment& out);
00142 
00143                 //TODO remove. but now is used from Time-Stretch
00145                 virtual const Frame& GetCurrentFrame(const Segment& in)
00146                 {
00147                         return in.GetFrame(mCurrentInputFrame);
00148                 }
00149                 
00151                 virtual Frame& GetCurrentFrame( Segment& out)
00152                 {
00153                         if(mCurrentInputFrame==out.GetnFrames() && mInput->GetnFrames()>out.GetnFrames())
00154                                 out.AddFrame(out.GetFrame((TIndex)out.GetnFrames()-1));
00155                         return out.GetFrame(mCurrentInputFrame);
00156                 }
00157 
00158                 //TODO remove. but now is used by SegmentSMSMorph
00159                 int mCurrentInputFrame;
00160 
00161         };
00162         
00163 };//namespace CLAM
00164 
00165 #endif // _SegmentTransformation_
00166 
Generated by  doxygen 1.6.3