CLAM-Development  1.4.0
SegmentTransformation.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef _SegmentTransformation_
23 #define _SegmentTransformation_
24 
25 
26 #include "Processing.hxx"
27 #include "ProcessingData.hxx"
28 #include "InPort.hxx"
29 #include "OutPort.hxx"
30 #include "OutControl.hxx"
31 #include "InControl.hxx"
32 #include "InControlPublisher.hxx"
33 #include "SpectralPeakArray.hxx"
34 #include "Frame.hxx"
35 #include "Segment.hxx"
37 
38 #include "FrameTransformation.hxx"
39 
40 namespace CLAM {
41 
43  {
44 
45  FrameTransformation* mFrameTransformation;
46 
47  protected:
48 // FloatOutControl mSendAmount; //TODO privatize
61 
64  public:
70 
71 
72  public:
73  void AttachIn( Segment& data ){ mInput = &data; }
74  void AttachOut( Segment& data ){ mOutput = &data; }
75 
77 
84  virtual bool ConcreteConfigure(const ProcessingConfig& c);
85 
86  const ProcessingConfig& GetConfig() const
87  {
88  return mConfig;
89  }
90 
93 
98 
99  virtual ~SegmentTransformation();
100 
104  virtual bool DoWithSegments(void)
105  {
106  return Do(*mInput, *mOutput);
107  }
108 
112  virtual bool UpdateControlValueFromBPF(TData pos);
113 
115  virtual bool IsLastFrame();
116 
118  bool ConcreteStart();
119 
120  protected:
121 
122 
123  virtual bool Do(const Frame& in,Frame& out) { return true; }
124  bool Do() { return true; }
125  const char* GetClassName() const { return "SegmentTransformation"; }
126 
127 
128  void AddFramesToOutputIfInputIsLonger(int frameindex, const Segment& in, Segment& out)
129  {
130  if(frameindex==out.GetnFrames() && in.GetnFrames()>out.GetnFrames())
131  out.AddFrame(out.GetFrame((TIndex)out.GetnFrames()-1));
132  }
133 
141  virtual bool Do(const Segment& in, Segment& out);
142 
143  //TODO remove. but now is used from Time-Stretch
145  virtual const Frame& GetCurrentFrame(const Segment& in)
146  {
147  return in.GetFrame(mCurrentInputFrame);
148  }
149 
151  virtual Frame& GetCurrentFrame( Segment& out)
152  {
154  out.AddFrame(out.GetFrame((TIndex)out.GetnFrames()-1));
155  return out.GetFrame(mCurrentInputFrame);
156  }
157 
158  //TODO remove. but now is used by SegmentSMSMorph
160 
161  };
162 
163 };//namespace CLAM
164 
165 #endif // _SegmentTransformation_
166