CLAM-Development
1.4.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
Processing
Transformations
SMS
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
22
#include "
SMSTransformationChain.hxx
"
23
24
//We should avoid having to include all SMS Transformations here: factory needed
25
#include "
SegmentTransformationConfig.hxx
"
26
#include "
SegmentSMSHarmonizer.hxx
"
27
#include "
SegmentSMSMorphConfig.hxx
"
28
#include "
SegmentSMSTimeStretchConfig.hxx
"
29
30
namespace
CLAM
31
{
32
// SMSTransformationChaineeConfig method definition
33
34
SMSTransformationChaineeConfig::~SMSTransformationChaineeConfig
()
35
{
36
if
(
mpConcreteConfig
)
37
delete
mpConcreteConfig
;
38
}
39
40
41
void
SMSTransformationChaineeConfig::DefaultInit
( )
42
{
43
AddAll();
44
UpdateData
();
45
SetConcreteClassName(
"Unknown"
);
46
mpConcreteConfig
=
NULL
;
47
}
48
49
void
SMSTransformationChaineeConfig::CopyInit
(
const
SMSTransformationChaineeConfig
& originalConfig)
50
{
51
AddAll();
52
UpdateData
();
53
mpConcreteConfig
=
NULL
;
54
SetConcreteConfig
(*(originalConfig.
mpConcreteConfig
));
55
}
56
57
void
SMSTransformationChaineeConfig::StoreOn
(
Storage
& s)
const
58
{
59
ProcessingConfig::StoreOn
(s);
60
mpConcreteConfig
->
StoreOn
(s);
61
}
62
63
void
SMSTransformationChaineeConfig::LoadFrom
(
Storage
& s)
64
{
65
ProcessingConfig::LoadFrom
(s);
66
mpConcreteConfig
=
InstantiateConcreteConfig
();
67
const_cast<
ProcessingConfig
*
>
(
mpConcreteConfig
)->
LoadFrom
(s);
68
}
69
70
ProcessingConfig
*
SMSTransformationChaineeConfig::InstantiateConcreteConfig
(
const
std::string& type)
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
{
78
return
new
CLAM::SegmentTransformationConfig
();
79
}
80
if
(type==
"SegmentSMSMorph"
)
81
return
new
CLAM::SegmentSMSMorphConfig
();
82
if
(type==
"SegmentSMSTimeStretch"
)
83
return
new
CLAM::SegmentSMSTimeStretchConfig
();
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
97
void
SMSTransformationChainConfig::DefaultInit
()
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
Generated by
1.8.1