CLAM-Development
1.4.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
Processing
Transformations
FDFilterGen.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 _SpectralFilterGen_
24
#define _SpectralFilterGen_
25
26
#include "
Processing.hxx
"
27
#include "
ProcessingData.hxx
"
28
#include "
DataTypes.hxx
"
29
#include "
Audio.hxx
"
30
#include "
OutPort.hxx
"
31
#include "
Spectrum.hxx
"
32
#include "
Enum.hxx
"
33
34
namespace
CLAM {
35
36
class
EFDFilterGenControls
:
public
Enum
37
{
38
public
:
39
40
EFDFilterGenControls
() :
Enum
(
ValueTable
(),
gain
) { }
41
EFDFilterGenControls
(
tValue
v) :
Enum
(
ValueTable
(), v) { }
42
EFDFilterGenControls
(std::string s) :
Enum
(
ValueTable
(), s) { }
43
~EFDFilterGenControls
() { };
44
45
Component
*
Species
()
const
46
{
47
return
new
EFDFilterGenControls
;
48
}
49
50
enum
51
{
52
gain
=0,
53
highcutoff
,
54
lowcutoff
,
55
passbandslope
,
56
stopbandslope
57
}
tEnum
;
58
59
static
tEnumValue
*
ValueTable
()
60
{
61
static
tEnumValue
sEnumValues[] =
62
{
63
{
gain
,
"gain"
},
64
{
highcutoff
,
"highcutoff"
},
65
{
lowcutoff
,
"lowcutoff"
},
66
{
passbandslope
,
"passbandslope"
},
67
{
stopbandslope
,
"stopbandslope"
},
68
{ 0,
NULL
}
69
};
70
return
sEnumValues;
71
}
72
};
73
75
class
EFDFilterType
:
public
Enum
76
{
77
public
:
78
79
EFDFilterType
() :
Enum
(
ValueTable
(),
eLowPass
) {}
80
EFDFilterType
(
tValue
v) :
Enum
(
ValueTable
(), v) {};
81
EFDFilterType
(std::string s) :
Enum
(
ValueTable
(), s) {};
82
83
enum
{
84
eLowPass
,
85
eHighPass
,
86
eBandPass
,
87
eStopBand
88
};
89
90
virtual
Component
*
Species
()
const
91
{
92
// TODO: This is a xapusa. I want a default constructor!
93
return
(
Component
*)
new
EFDFilterType
(
eLowPass
);
94
};
95
static
tEnumValue
*
ValueTable
()
96
{
97
static
tEnumValue
sEnumValues[] = {
98
{
eLowPass
,
"Low-pass"
},
99
{
eHighPass
,
"High-pass"
},
100
{
eBandPass
,
"Band-pass"
},
101
{
eStopBand
,
"Stop-Band"
},
102
{0,
NULL
}
103
};
104
return
sEnumValues;
105
}
106
};
107
108
110
class
FDFilterGenConfig
:
public
ProcessingConfig
111
{
112
public
:
113
DYNAMIC_TYPE_USING_INTERFACE
(
FDFilterGenConfig
, 7,
ProcessingConfig
);
114
DYN_ATTRIBUTE
(0,
public
,
EFDFilterType
, Type);
115
DYN_ATTRIBUTE
(1,
public
,
TData
, SpectralRange);
116
DYN_ATTRIBUTE
(2,
public
,
TData
, Gain);
117
DYN_ATTRIBUTE
(3,
public
,
TData
, HighCutOff);
118
DYN_ATTRIBUTE
(4,
public
,
TData
, LowCutOff);
119
DYN_ATTRIBUTE
(5,
public
,
TData
, PassBandSlope);
120
DYN_ATTRIBUTE
(6,
public
,
TData
, StopBandSlope);
121
protected
:
122
void
DefaultInit
(
void
);
123
};
124
126
class
FDFilterGen
:
public
Processing
127
{
128
private
:
129
typedef
FDFilterGenConfig
Config
;
130
131
public
:
132
OutPort<Spectrum>
Output
;
133
134
FloatInControl
Gain
;
135
FloatInControl
HighCutOff
;
136
FloatInControl
LowCutOff
;
137
FloatInControl
PassBandSlope
;
138
FloatInControl
StopBandSlope
;
139
140
private
:
141
TData
SpectralRange;
142
EFDFilterType
Type;
143
144
Config
mConfig;
145
146
bool
mControlChanged;
147
protected
:
148
149
// Control change callback function
150
void
UpdateControlChangedFlag
(
TControlData
);
151
152
153
public
:
154
158
FDFilterGen
(
const
Config
&c =
Config
());
159
160
161
virtual
~FDFilterGen
()
162
{
163
}
167
bool
Do
();
168
177
bool
Do
(
Spectrum
&out);
178
180
const
ProcessingConfig
&
GetConfig
()
const
{
return
mConfig; };
181
182
private
:
183
184
const
char
*GetClassName()
const
{
return
"FDFilterGen"
;}
185
187
bool
ConcreteConfigure(
const
ProcessingConfig& c);
188
190
void
SetFilterPoint(
191
Spectrum& out,
192
TIndex
pos,
193
TData
freq,
194
TData
mag,
195
TData
phase=0
196
);
197
198
};
199
200
}
//namespace CLAM
201
202
203
#endif // _FFT_
204
Generated by
1.8.1