CLAM-Development
1.4.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
Processing
Generators
SimpleOscillator.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
#ifndef __SimpleOscillator_hxx__
23
#define __SimpleOscillator_hxx__
24
25
#include "
Processing.hxx
"
26
#include "
ProcessingData.hxx
"
27
#include "
OSDefines.hxx
"
28
#include "
Audio.hxx
"
29
#include "
AudioOutPort.hxx
"
30
#include "
InControl.hxx
"
31
#include "
Enum.hxx
"
32
#include <string>
33
34
namespace
CLAM
35
{
36
37
class
EOscillatorControls
:
public
Enum
38
{
39
public
:
40
41
EOscillatorControls
() :
Enum
(
ValueTable
(),
pitch
) { }
42
EOscillatorControls
(
tValue
v) :
Enum
(
ValueTable
(), v) { }
43
EOscillatorControls
(std::string s) :
Enum
(
ValueTable
(), s) { }
44
~EOscillatorControls
() { };
45
46
Component
*
Species
()
const
47
{
48
return
new
EOscillatorControls
;
49
}
50
typedef
enum
51
{
52
pitch
=0,
53
amplitude
,
54
modidx
,
55
phase
56
}
tEnum
;
57
static
tEnumValue
*
ValueTable
()
58
{
59
static
tEnumValue
sEnumValues[] =
60
{
61
{
pitch
,
"pitch"
},
62
{
amplitude
,
"amplitude"
},
63
{
modidx
,
"modidx"
},
64
{
phase
,
"phase"
},
65
{ 0,
NULL
}
66
};
67
return
sEnumValues;
68
}
69
};
70
71
class
SimpleOscillatorConfig
:
public
ProcessingConfig
72
{
73
public
:
74
DYNAMIC_TYPE_USING_INTERFACE
(
SimpleOscillatorConfig
, 4,
ProcessingConfig
);
75
DYN_ATTRIBUTE
(0,
public
,
TData
, Frequency);
76
DYN_ATTRIBUTE
(1,
public
,
TData
, Amplitude);
77
DYN_ATTRIBUTE
(2,
public
,
TData
, Phase);
78
DYN_ATTRIBUTE
(3,
public
,
TData
, SamplingRate);
79
80
protected
:
81
void
DefaultInit
(
void
);
82
};
83
84
class
SimpleOscillator
:
public
Processing
85
{
86
protected
:
87
typedef
SimpleOscillatorConfig
Config
;
88
AudioOutPort
mOutput
;
89
SimpleOscillatorConfig
mConfig
;
90
TData
mAmp
;
91
TData
mPhase
;
92
TData
mDeltaPhase
;
93
TData
mSamplingRate
;
94
95
bool
mFreqUpdated
;
96
bool
mAmpUpdated
;
97
FloatInControl
mFreqCtl
;
98
FloatInControl
mAmpCtl
;
99
//xamat: kludge to convert this into an LFO, eventually separate into a different class
100
FloatInControl
mSamplesBetweenCallsCtl
;
101
102
protected
:
103
104
inline
void
ApplyFreqAndAmpControls
()
105
{
106
if
(
mFreqUpdated
)
107
{
108
mDeltaPhase
=
TData
(2. *
PI
*
mFreqCtl
.
GetLastValue
() /
mSamplingRate
);
109
mFreqUpdated
=
false
;
110
}
111
if
(
mAmpUpdated
)
112
{
113
mAmp
=
mAmpCtl
.
GetLastValue
();
114
mAmpUpdated
=
false
;
115
}
116
}
117
118
void
UpdateFreq
(
TControlData
);
119
void
UpdateAmp
(
TControlData
);
120
121
public
:
122
123
SimpleOscillator
(
const
SimpleOscillatorConfig
& c =
Config
() );
124
125
virtual
~SimpleOscillator
();
126
127
const
char
*
GetClassName
()
const
{
return
"SimpleOscillator"
;}
128
129
virtual
const
ProcessingConfig
&
GetConfig
()
const
{
return
mConfig
;}
130
131
virtual
bool
ConcreteConfigure
(
const
ProcessingConfig
& c);
132
133
virtual
bool
Do
(
void
);
134
135
// "Generative Do"
136
bool
Do
(
Audio
& out);
138
bool
Do
(
TData
& out);
139
};
140
141
}
142
143
#endif
144
145
Generated by
1.8.1