CLAM-Development  1.4.0
SMSTimeStretch.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 _SMSTimeStretch_
23 #define _SMSTimeStretch_
24 
25 #include "Processing.hxx"
26 #include "Frame.hxx"
27 #include "InPort.hxx"
28 #include "OutPort.hxx"
29 #include "InControl.hxx"
30 #include "SMSTimeStretchConfig.hxx"
31 #include "SpectrumInterpolator.hxx"
33 
34 // FIXME
35 // #include "FrameInterpolator.hxx"
36 
37 namespace CLAM{
38 
44  class SMSTimeStretch: public Processing
45  {
46 
47  //TODO introduce interpolation of spectral shapes, before that, interpolations may be extracted to external Processing's (this comment is also in doxygen class description)
48  const char *GetClassName() const {return "SMSTimeStretch";}
49 
52  InPort<Fundamental> mInFund;
53  OutPort<Fundamental> mOutFund;
54  InPort<Spectrum> mInSpectrum;
55  OutPort<Spectrum> mOutSpectrum;
56 
57 
58  public:
60  :
61  mInPeaks("In SpectralPeaks", this),
62  mOutPeaks("Out SpectralPeaks", this),
63  mInFund("In Fundamental", this),
64  mOutFund("Out Fundamental", this),
65  mInSpectrum("In Spectrum", this),
66  mOutSpectrum("Out Spectrum", this)
67  {
68  Configure( mConfig );
69  }
70 
72 
73  bool Do()
74  {
75  bool result = Do(mInPeaks.GetData(),
76  mInFund.GetData(),
77  mInSpectrum.GetData(),
78  mOutPeaks.GetData(),
79  mOutFund.GetData(),
80  mOutSpectrum.GetData()
81  );
82 
83  mInPeaks.Consume();
84  mInFund.Consume();
85  mInSpectrum.Consume();
86  mOutPeaks.Produce();
87  mOutFund.Produce();
88  mOutSpectrum.Produce();
89 
90  return result;
91  }
92 
93  bool Do(const Frame& in, Frame& out);
94 
95  bool Do(const SpectralPeakArray& inPeaks,
96  const Fundamental& inFund,
97  const Spectrum& inSpectrum,
98  SpectralPeakArray& outPeaks,
99  Fundamental& outFund,
100  Spectrum& outSpectrum
101  );
102 
103 
104 //FIXME
105  bool ConcreteStart();
106  bool ConcreteStop();
107 
108 // bool CanProcessInplace() {return false;}
109 // bool IsLastFrame();
110 //
111 // Frame& GetCurrentFrame(Segment& out);
112 // const Frame& GetCurrentFrame(const Segment& in);
113 //
114 
115 // FloatInControl mFactor;
116 
118 
119  const ProcessingConfig & GetConfig() const
120  {
121  return mConfig;
122  }
123 
124  protected:
125  bool ConcreteConfigure(const ProcessingConfig& config);
126 
127  private:
128  Config mConfig;
129 
130  protected:
131 // bool HaveFinished();
132 // void UpdateTimeAndIndex(const Segment& in);
133 
137 
139 
141 // FrameInterpolator mFrameInterpolator; // FIXME
144  };
145 };//namespace CLAM
146 
147 #endif // _SMSTimeStretch_