CLAM-Development  1.4.0
FrameAdder.cxx
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 #include "Complex.hxx"
23 #include "SpecTypeFlags.hxx"
24 #include "FrameAdder.hxx"
25 #include "BPF.hxx"
26 #include "Point.hxx"
27 
28 namespace CLAM {
29 
31  : mIn1("Input 1",this),
32  mIn2("Input 2",this),
33  mOut("Output",this)
34  {
35  AttachChildren();
37  }
38 
40  : mIn1("Input 1",this),
41  mIn2("Input 2",this),
42  mOut("Output",this)
43  {
44  AttachChildren();
45  Configure(c);
46  }
47 
48 
49  bool FrameAdder::ConcreteConfigure(const ProcessingConfig&c)
50  {
51  CopyAsConcreteConfig(mConfig, c);
52 
53  return true;
54  }
55 
56  void FrameAdder::AttachChildren()
57  {
58  mPO_SpectrumAdder.SetParent(this);
59  mPO_PeaksAdder.SetParent(this);
60  }
61 
62 
63  // Unsupervised Do() function.
64  bool FrameAdder::Do(const Frame& in1, const Frame& in2, Frame& out)
65  {
67  "FrameAdder::Do(): Not in execution mode");
68 
72  if(out.GetFundamental().GetnCandidates()==0)
73  out.GetFundamental().AddElem(0,0);
74  else
75  out.GetFundamental().SetFreq(0,0);
76  out.GetFundamental().SetnCandidates(1);
77 
79  //SpectralPeakArrayAdder cannot process inplace, by making this temporal
80  //copy we allow FrameAdder to process inplace
81  SpectralPeakArray tmpPeakArray;
82 
83  mPO_PeaksAdder.Do(in1.GetSpectralPeakArray(),in2.GetSpectralPeakArray(),tmpPeakArray);
84  out.SetSpectralPeakArray(tmpPeakArray);
86  mPO_SpectrumAdder.Do(in1.GetResidualSpec(),in2.GetResidualSpec(),out.GetResidualSpec());
87 
88  return true;
89  }
90 
91  bool FrameAdder::Do(void)
92  {
93  CLAM_ASSERT(false,"FrameAdder::Do(): Not implemented");
94 
95  return true;
96  }
97 
98 
99 
100 
101 
102 }
103