CLAM-Development  1.4.0
SpectralShapeShift.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 
23 #ifndef _SpectralShapeShift_
24 #define _SpectralShapeShift_
25 
28 #include "Frame.hxx"
29 #include "FDCombFilter.hxx"
30 #include "InPort.hxx"
31 #include "OutPort.hxx"
32 #include "InControl.hxx"
33 #include "FrameTransformation.hxx"
36 #include "SpectralPeakDetect.hxx"
37 
38 namespace CLAM{
39 
40 
46  {
47 
48  const char *GetClassName() const {return "SpectralShapeShift";}
49 
50  InPort<Spectrum> mIn;
51  OutPort<Spectrum> mOut;
52 
53  FloatInControl mSteps;
54  public:
55 
57  :
58  mIn( "InSpectrum", this),
59  mOut( "OutSpectrum", this),
60  mSteps("Shift Steps", this)
61  {
63  mSpectralRange=22050; //default
64  mSpectralPeaks.AddAll();
65  mSpectralPeaks.UpdateData();
66  mSpectralPeaks.SetScale(EScale::eLog);
67  mSpectralEnvelope.AddAll();
68  mSpectralEnvelope.UpdateData();
69 
71  cfg.SetMagThreshold(-80.f);
72  cfg.SetMaxPeaks(200);
73  cfg.SetMaxFreq(15000.f);
74  mSpectralPeakDetect.Configure(cfg);
75 
77  envCfg.SetMaxPeaks(1000);
78  mSpectralEnvelopeExtract.Configure(envCfg);
79  }
80 
82 
83  bool Do(const Frame& in, Frame& out)
84  {
85  return Do(in.GetSpectrum(),
86  out.GetSpectrum());
87  }
88 
89  bool Do(const Spectrum& inpeaks,Spectrum& out);
90 
91  bool Do()
92  {
93  bool result = Do(mIn.GetData(), mOut.GetData());
94  mIn.Consume();
95  mOut.Produce();
96  return result;
97  }
98 
99  private:
100  SpectralEnvelopeExtract mSpectralEnvelopeExtract;
101  SpectralEnvelopeApply mSpectralEnvelopeApply;
102  SpectralPeakDetect mSpectralPeakDetect;
103  Spectrum mSpectralEnvelope;
104  Spectrum mLogSpectrum;
105  SpectralPeakArray mSpectralPeaks;
106  TSize mSpectralRange;
107  };
108 } //namespace CLAM
109 
110 #endif // _SpectralShapeShift_
111