CLAM-Development  1.4.0
SMSMorph.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 _SMSMorph_
23 #define _SMSMorph_
24 
25 #include "SMSMorphConfig.hxx"
26 
27 #include "Processing.hxx"
28 #include "Frame.hxx"
29 #include "InPort.hxx"
30 #include "OutPort.hxx"
31 #include "InControl.hxx"
32 #include "SpectrumInterpolator.hxx"
34 
35 
36 namespace CLAM{
37 
42  class SMSMorph: public Processing
43  {
44  const char *GetClassName() const {return "SMSMorph";}
45 
46  InPort<SpectralPeakArray> mInPeaks1;
47  InPort<Fundamental> mInFund1;
48  InPort<Spectrum> mInSpectrum1;
49 
50  InPort<SpectralPeakArray> mInPeaks2;
51  InPort<Fundamental> mInFund2;
52  InPort<Spectrum> mInSpectrum2;
53 
54  //TODO add many sources morph option? (with configurable amount)
55 
57  OutPort<Fundamental> mOutFund;
58  OutPort<Spectrum> mOutSpectrum;
59 
63  FloatInControl mInterpolationFactor;
64 
65  public:
67  :
68  mInPeaks1("In SpectralPeaks 1", this),
69  mInFund1("In Fundamental 1", this),
70  mInSpectrum1("In Spectrum 1", this),
71 
72  mInPeaks2("In SpectralPeaks 2", this),
73  mInFund2("In Fundamental 2", this),
74  mInSpectrum2("In Spectrum 2", this),
75 
76  mOutPeaks("Out SpectralPeaks", this),
77  mOutFund("Out Fundamental", this),
78  mOutSpectrum("Out Spectrum", this),
79 
80  mInterpolationFactor("Interpolation Factor", this)
81  {
82  Configure( mConfig );
83  }
84 
85  ~SMSMorph() {}
86 
87  bool Do()
88  {
89  bool result = Do(mInPeaks1.GetData(),
90  mInFund1.GetData(),
91  mInSpectrum1.GetData(),
92  mInPeaks2.GetData(),
93  mInFund2.GetData(),
94  mInSpectrum2.GetData(),
95  mOutPeaks.GetData(),
96  mOutFund.GetData(),
97  mOutSpectrum.GetData()
98  );
99 
100  mInPeaks1.Consume();
101  mInFund1.Consume();
102  mInSpectrum1.Consume();
103 
104  mInPeaks2.Consume();
105  mInFund2.Consume();
106  mInSpectrum2.Consume();
107 
108  mOutPeaks.Produce();
109  mOutFund.Produce();
110  mOutSpectrum.Produce();
111 
112  return result;
113  }
114 
115  bool Do(const SpectralPeakArray& inPeaks1,
116  const Fundamental& inFund1,
117  const Spectrum& inSpectrum1,
118  const SpectralPeakArray& inPeaks2,
119  const Fundamental& inFund2,
120  const Spectrum& inSpectrum2,
121  SpectralPeakArray& outPeaks,
122  Fundamental& outFund,
123  Spectrum& outSpectrum
124  );
125 
126  //TODO - check if it's still useful
127  bool Do(const Frame& in1, const Frame& in2, Frame& out);
128 
130 
132  {
133  return mConfig;
134  }
135 
136  private:
137  Config mConfig;
138 
139  protected:
140  bool ConcreteConfigure(const ProcessingConfig& c);
141 
142 
146 
147  };
148 };//namespace CLAM
149 
150 #endif // _SMSMorph_
151