CLAM-Development  1.4.0
SegmentTransformation.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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 
23 
24 namespace CLAM
25 {
27  {
28  CLAM_ASSERT( !mFrameTransformation, "SegmentTransformation::Wrapp object shoudn't have wrapped transformation");
29  mFrameTransformation = trans;
30  }
31 
33  : mOnCtrl("On",this)
34  , mAmountCtrl("Amount",this)
35  {
36  mInput = 0;
37  mOutput = 0;
38  mUseTemporalBPF = 0;
40  mFrameTransformation = 0;
41  }
42 
44  : mOnCtrl("On",this)
45  , mAmountCtrl("Amount",this)
46  {
47  mInput = 0;
48  mOutput = 0;
49  mUseTemporalBPF = 0;
51  Configure(c);
52  mFrameTransformation = 0;
53  }
54 
56  {
57  if (mFrameTransformation)
58  delete mFrameTransformation;
59  };
60 
62  {
63  CLAM_ASSERT(mInput==&in, "sms transformation chain needs input segment");
64  //TODO find out why this finalization condition (and not just using size)
66  {
67  if(mUseTemporalBPF)
69 
71 
72  const Frame & inframe = in.GetFrame(mCurrentInputFrame);
73  Frame & outframe = out.GetFrame(mCurrentInputFrame);
74 
75  if (mFrameTransformation)
76  {
77  mFrameTransformation->Do(inframe, outframe);
78  }
79  else //TODO remove when refactoring is done
80  {
81  Do( inframe, outframe );
82  }
83 
84 
85 
86  if(&in!=&out)
87  out.mCurrentFrameIndex++;
88 
90  }
91  return true;
92  }
93 
95  {
97  mUseTemporalBPF=false;
98  if(mConfig.HasAmount())
99  {
100  mAmountCtrl.DoControl(mConfig.GetAmount());
101  }
102  else if(mConfig.HasBPFAmount()){
103  mAmountCtrl.DoControl(mConfig.GetBPFAmount().GetValue(0));
104  mUseTemporalBPF=true;
105  }
106  else
107  {
109  }
110 
111  return true;
112  }
113 
115  {
116  if(mConfig.HasBPFAmount())
117  {
118  TControlData amount = mConfig.GetBPFAmount().GetValue(pos);
119  mAmountCtrl.DoControl(amount);
120  return true;
121  }
122  else return false;
123  }
124 
126  {
127  bool isLast=mInput->mCurrentFrameIndex >= mInput->GetnFrames();
128 
129  if(isLast)
130  {
132  {
134  }
135  }
136  return isLast;
137  }
138 
140  {
141  return true;
142  }
143 
144 
145 
146 }
147