CLAM-Development  1.4.0
SMSTransformationChainConfig.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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 
23 
24 //We should avoid having to include all SMS Transformations here: factory needed
26 #include "SegmentSMSHarmonizer.hxx"
29 
30 namespace CLAM
31 {
32  // SMSTransformationChaineeConfig method definition
33 
35  {
36  if(mpConcreteConfig)
37  delete mpConcreteConfig;
38  }
39 
40 
42  {
43  AddAll();
44  UpdateData();
45  SetConcreteClassName("Unknown");
47  }
48 
50  {
51  AddAll();
52  UpdateData();
54  SetConcreteConfig(*(originalConfig.mpConcreteConfig));
55  }
56 
58  {
61  }
62 
64  {
67  const_cast<ProcessingConfig*>(mpConcreteConfig)->LoadFrom(s);
68  }
69 
71  {
72  if(type=="SMSDummyTransformation"||type=="SMSFreqShift"||type=="SMSPitchShift"||
73  type=="SMSOddEvenHarmonicRatio"||type=="SMSSineFilter"||type=="SMSResidualGain"||
74  type=="SegmentSMSHarmonizer"||type=="SMSSinusoidalGain"||type=="SMSPitchDiscretization"||
75  type=="SMSSpectralShapeShift"||type=="SMSGenderChange"||
76  type=="SMSTransformationChainIO")
77  {
79  }
80  if (type=="SegmentSMSMorph")
81  return new CLAM::SegmentSMSMorphConfig();
82  if (type=="SegmentSMSTimeStretch")
84 
85  // error let's investigate
86  CLAM_ASSERT(type!="Unknown",
87  "Before instantiating a concrete configuration, you have to set its class name");
88 
89  std::string error="SMSTransformationChaineeConfig::InstantiateConcreteConfig: "
90  "Trying to instantiate a non-valid Configuration: ";
91  error+=type;
92  CLAM_ASSERT(false,error.c_str());
93  return 0;
94  }
95 
96  // SMSTransformationChainConfig method definition
98  {
99  AddAll();
100  UpdateData();
101  }
102 
103  void SMSTransformationChainConfig::AddConfiguration(const ProcessingConfig& newConcreteConfig,const std::string& className)
104  {
105  SMSTransformationChaineeConfig newChaineeConfig;
106  newChaineeConfig.SetConcreteClassName(className);
107  newChaineeConfig.SetConcreteConfig(newConcreteConfig);
108 
109  //We first resize and set to false by default, on array
110  GetOnArray().Resize(GetnConfigurations()+1);
111  GetOnArray().SetSize(GetnConfigurations()+1);
112  GetOnArray()[GetnConfigurations()]=false;
113 
114  GetConfigurations().push_back(newChaineeConfig);
115 
116  }
117 
118 }
119