SMSTransformationChainConfig.cxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #include "SMSTransformationChain.hxx"
00023 
00024 //We should avoid having to include all SMS Transformations here: factory needed
00025 #include "SegmentTransformationConfig.hxx"
00026 #include "SegmentSMSHarmonizer.hxx"
00027 #include "SegmentSMSMorphConfig.hxx"
00028 #include "SegmentSMSTimeStretchConfig.hxx"
00029 
00030 namespace CLAM
00031 {
00032         // SMSTransformationChaineeConfig method definition
00033 
00034         SMSTransformationChaineeConfig::~SMSTransformationChaineeConfig()
00035         {
00036                 if(mpConcreteConfig) 
00037                         delete mpConcreteConfig;
00038         }
00039 
00040 
00041         void SMSTransformationChaineeConfig::DefaultInit( )
00042         {
00043                 AddAll();
00044                 UpdateData();
00045                 SetConcreteClassName("Unknown");
00046                 mpConcreteConfig=NULL;
00047         }
00048 
00049         void SMSTransformationChaineeConfig::CopyInit(const SMSTransformationChaineeConfig& originalConfig)
00050         {
00051                 AddAll();
00052                 UpdateData();
00053                 mpConcreteConfig=NULL;
00054                 SetConcreteConfig(*(originalConfig.mpConcreteConfig));
00055         }
00056 
00057         void SMSTransformationChaineeConfig::StoreOn(Storage & s) const
00058         {
00059                 ProcessingConfig::StoreOn(s);
00060                 mpConcreteConfig->StoreOn(s);
00061         }
00062         
00063         void SMSTransformationChaineeConfig::LoadFrom(Storage& s)
00064         {
00065                 ProcessingConfig::LoadFrom(s);
00066                 mpConcreteConfig=InstantiateConcreteConfig();
00067                 const_cast<ProcessingConfig*>(mpConcreteConfig)->LoadFrom(s);
00068         }
00069 
00070         ProcessingConfig* SMSTransformationChaineeConfig::InstantiateConcreteConfig(const std::string& type)
00071         {
00072                 if(type=="SMSDummyTransformation"||type=="SMSFreqShift"||type=="SMSPitchShift"||
00073                    type=="SMSOddEvenHarmonicRatio"||type=="SMSSineFilter"||type=="SMSResidualGain"||
00074                    type=="SegmentSMSHarmonizer"||type=="SMSSinusoidalGain"||type=="SMSPitchDiscretization"||
00075                    type=="SMSSpectralShapeShift"||type=="SMSGenderChange"||
00076                    type=="SMSTransformationChainIO")
00077                 {
00078                         return new CLAM::SegmentTransformationConfig();
00079                 }
00080                 if (type=="SegmentSMSMorph") 
00081                         return new CLAM::SegmentSMSMorphConfig();
00082                 if (type=="SegmentSMSTimeStretch")
00083                         return new CLAM::SegmentSMSTimeStretchConfig();
00084 
00085                 // error let's investigate
00086                 CLAM_ASSERT(type!="Unknown",
00087                         "Before instantiating a concrete configuration, you have to set its class name");
00088 
00089                 std::string error="SMSTransformationChaineeConfig::InstantiateConcreteConfig: "
00090                         "Trying to instantiate a non-valid Configuration: ";
00091                 error+=type;
00092                 CLAM_ASSERT(false,error.c_str());
00093                 return 0;
00094         }
00095         
00096         // SMSTransformationChainConfig method definition
00097         void SMSTransformationChainConfig::DefaultInit()
00098         {
00099                 AddAll();
00100                 UpdateData();
00101         }
00102 
00103         void SMSTransformationChainConfig::AddConfiguration(const ProcessingConfig& newConcreteConfig,const std::string& className)
00104         {
00105                 SMSTransformationChaineeConfig newChaineeConfig;
00106                 newChaineeConfig.SetConcreteClassName(className);
00107                 newChaineeConfig.SetConcreteConfig(newConcreteConfig);
00108                         
00109                 //We first resize and set to false by default, on array
00110                 GetOnArray().Resize(GetnConfigurations()+1);
00111                 GetOnArray().SetSize(GetnConfigurations()+1);
00112                 GetOnArray()[GetnConfigurations()]=false;
00113                 
00114                 GetConfigurations().push_back(newChaineeConfig);
00115                 
00116         }
00117         
00118 }
00119 
Generated by  doxygen 1.6.3