CLAM-Development  1.4.0
SMSSynthesis.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 _SMSSynthesis_
23 #define _SMSSynthesis_
24 
25 #include "SMSSynthesisConfig.hxx"
26 #include "ProcessingComposite.hxx"
27 
28 #include "Array.hxx"
29 #include "Audio.hxx"
30 #include "DataTypes.hxx"
31 #include "DynamicType.hxx"
32 #include "Err.hxx"
33 #include "Frame.hxx"
34 #include "Segment.hxx"
35 #include "InControl.hxx"
36 #include "Spectrum.hxx"
37 #include "ProcessingData.hxx"
38 #include "ProcessingDataConfig.hxx"
39 #include "Processing.hxx"
40 #include "SynthSineSpectrum.hxx"
41 #include "PhaseManagement.hxx"
42 #include "SpectralSynthesis.hxx"
43 #include "SpectrumAdder2.hxx"
44 #include "SMSAnalysis.hxx"
45 
46 #include "InPort.hxx"
47 #include "OutPort.hxx"
48 #include "AudioOutPort.hxx"
49 
50 #include <stdlib.h>
51 
52 namespace CLAM {
53 
58 
59  private:
60  // Configuration data
61  typedef SMSSynthesisConfig Config;
62  Config mConfig;
63 
64  int mCurrentFrame;
65 
66  //internal Processing Objects
71  SpectralSynthesis mSinSpectralSynthesis;
72  SpectralSynthesis mResSpectralSynthesis;
73  SpectralSynthesis mSpectralSynthesis;
74  SynthSineSpectrum mSynthSineSpectrum;
75  PhaseManagement mPhaseMan;
76  SpectrumAdder2 mSpectrumAdder;
77 
78  OverlapAdd mOverlapAddSin;
79  OverlapAdd mOverlapAddRes;
80  OverlapAdd mOverlapAddGlobal;
81 
82 
83 
85  Audio mAudioFrame;
86 
87  // Internal convenience methods.
88 
89  void AttachChildren();
90  bool ConfigureChildren();
91  void ConfigureData();
92 
93 
95  bool ConcreteConfigure(const ProcessingConfig&);
96 
97  TInt32 CalculatePowerOfTwo(TInt32 size);
98 
99  public:
100  SMSSynthesis(const Config& cfg = Config());
101  ~SMSSynthesis();
102 
103  // Processing Object compliance methods.
104 
105  const char *GetClassName() const {return "SMSSynthesis";}
106 
107 
108  const ProcessingConfig &GetConfig() const {return mConfig;}
109 
111  bool Do(void);
112 
114  bool SinusoidalSynthesis(const SpectralPeakArray& in,Spectrum& outSpec,Audio& outAudio);
116  bool SinusoidalSynthesis(const SpectralPeakArray& in,Audio& out);
117 
121  bool Do(SpectralPeakArray& inputSinusoidalPeaks, Spectrum& inputResidualSpectrum,
122  Spectrum& outputSinusoidalSpectrum, Spectrum& outputSpectrum,
123  Audio& outputAudio, Audio& outputSinusoidalAudio, Audio& outputResidualAudio);
124 
128  bool Do(SpectralPeakArray& inputSinusoidalPeaks, Spectrum& inputResidualSpectrum,
129  Spectrum& outputSinusoidalSpectrum, Spectrum& outputSpectrum,
130  Audio& outputAudio);
131 
136  bool Do(SpectralPeakArray& inputSinusoidal, Spectrum& inputSpectrum,
137  Audio& outputAudio, Audio& outputSinusoidal, Audio& outputResidual);
139  bool Do(Frame& in);
149  bool Do(Frame& in, bool isSynthesizeSinusoidsAndResidual);
152  bool Do(Segment& in);
153  protected:
154 
155  void InitFrame(Frame& in);
156 
165 
166  public:
167  //Controls
170 
171 
172  };
173 
174 }; //end of namespace
175 
176 #endif //_SMSSynthesis_
177