FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
AS/src/VCA.cpp at V2 · AScustomWorks/AS · GitHub
AScustomWorks
/
AS
Public
Notifications
You must be signed in to change notification settings
Fork
16
Star
123
Code
Issues
15
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
AS
/
src
/
VCA.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
114 lines (95 loc) · 3.73 KB
Breadcrumbs
AS
/
src
/
VCA.cpp
Copy path
File metadata and controls
executable file
·
114 lines (95 loc) · 3.73 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//
**************************************************************************************
//
VCA module for VCV Rack by Alfredo Santamaria - AS - https://github.com/AScustomWorks/AS
//
//
Code taken from the Fundamentals plugins by Andrew Belt http://www.vcvrack.com
//
**************************************************************************************
#
include
"
AS.hpp
"
struct
VCA
: Module {
enum
ParamIds {
LEVEL1_PARAM
,
LEVEL2_PARAM
,
MODE1_PARAM
,
MODE2_PARAM
,
NUM_PARAMS
};
enum
InputIds {
ENV1_INPUT
,
IN1_INPUT
,
ENV2_INPUT
,
IN2_INPUT
,
NUM_INPUTS
};
enum
OutputIds {
OUT1_OUTPUT
,
OUT2_OUTPUT
,
NUM_OUTPUTS
};
float
v1=
0
.
0f
;
float
v2=
0
.
0f
;
const
float
expBase =
50
.
0f
;
bool
env1_mode_cv;
bool
env2_mode_cv;
VCA
() {
config
(
NUM_PARAMS
,
NUM_INPUTS
,
NUM_OUTPUTS
);
configParam
(
VCA
::
LEVEL1_PARAM
,
0
.
0f
,
1
.
0f
,
0
.
5f
,
"
CH 1 Gain
"
,
"
%
"
,
0
.
0f
,
100
.
0f
);
configParam
(
VCA
::
LEVEL2_PARAM
,
0
.
0f
,
1
.
0f
,
0
.
5f
,
"
CH 2 Gain
"
,
"
%
"
,
0
.
0f
,
100
.
0f
);
//
New in V2, config switches and ports info without displaying values
configSwitch
(
MODE1_PARAM
,
0
.
0f
,
1
.
0f
,
1
.
0f
,
"
CH 1 Response
"
, {
"
Exponential
"
,
"
Linear
"
});
configSwitch
(
MODE2_PARAM
,
0
.
0f
,
1
.
0f
,
1
.
0f
,
"
CH 2 Response
"
, {
"
Exponential
"
,
"
Linear
"
});
//
inputs
configInput
(
ENV1_INPUT
,
"
CH 1 Gain CV
"
);
configInput
(
ENV2_INPUT
,
"
CH 2 Gain CV
"
);
configInput
(
IN1_INPUT
,
"
CH 1
"
);
configInput
(
IN2_INPUT
,
"
CH 2
"
);
//
Outputs
configOutput
(
OUT1_OUTPUT
,
"
CH 1
"
);
configOutput
(
OUT2_OUTPUT
,
"
CH 2
"
);
}
void
process
(
const
ProcessArgs &args)
override
{
//
VCA 1
v1 = inputs[
IN1_INPUT
].
getVoltage
() * params[
LEVEL1_PARAM
].
getValue
();
if
(inputs[
ENV1_INPUT
].
isConnected
()){
if
(params[
MODE1_PARAM
].
getValue
()==
1
){
v1 *=
clamp
(inputs[
ENV1_INPUT
].
getVoltage
() /
10
.
0f
,
0
.
0f
,
1
.
0f
);
}
else
{
v1 *=
rescale
(
powf
(expBase,
clamp
(inputs[
ENV1_INPUT
].
getVoltage
() /
10
.
0f
,
0
.
0f
,
1
.
0f
)),
1
.
0f
, expBase,
0
.
0f
,
1
.
0f
);
}
}
outputs[
OUT1_OUTPUT
].
setVoltage
(v1);
//
VCA 2
v2 = inputs[
IN2_INPUT
].
getVoltage
() * params[
LEVEL2_PARAM
].
getValue
();
if
(inputs[
ENV2_INPUT
].
isConnected
()){
if
(params[
MODE2_PARAM
].
getValue
()){
v2 *=
clamp
(inputs[
ENV2_INPUT
].
getVoltage
() /
10
.
0f
,
0
.
0f
,
1
.
0f
);
}
else
{
v2 *=
rescale
(
powf
(expBase,
clamp
(inputs[
ENV2_INPUT
].
getVoltage
() /
10
.
0f
,
0
.
0f
,
1
.
0f
)),
1
.
0f
, expBase,
0
.
0f
,
1
.
0f
);
}
}
outputs[
OUT2_OUTPUT
].
setVoltage
(v2);
}
};
struct
VCAWidget
: ModuleWidget {
VCAWidget
(
VCA
*
module
) {
setModule
(
module
);
setPanel
(
APP
->
window
->
loadSvg
(
asset::plugin
(pluginInstance,
"
res/VCA.svg
"
)));
//
SCREWS
addChild
(createWidget<as_HexScrew>(
Vec
(
RACK_GRID_WIDTH
,
0
)));
addChild
(createWidget<as_HexScrew>(
Vec
(box.
size
.
x
-
2
*
RACK_GRID_WIDTH
,
0
)));
addChild
(createWidget<as_HexScrew>(
Vec
(
RACK_GRID_WIDTH
,
RACK_GRID_HEIGHT
-
RACK_GRID_WIDTH
)));
addChild
(createWidget<as_HexScrew>(
Vec
(box.
size
.
x
-
2
*
RACK_GRID_WIDTH
,
RACK_GRID_HEIGHT
-
RACK_GRID_WIDTH
)));
//
SLIDERS
addParam
(createParam<as_SlidePot>(
Vec
(
10
,
70
),
module
,
VCA
::
LEVEL1_PARAM
));
addParam
(createParam<as_SlidePot>(
Vec
(
55
,
70
),
module
,
VCA
::
LEVEL2_PARAM
));
//
MODE SWITCHES
addParam
(createParam<as_CKSS>(
Vec
(
14
,
190
),
module
,
VCA
::
MODE1_PARAM
));
addParam
(createParam<as_CKSS>(
Vec
(
59
,
190
),
module
,
VCA
::
MODE2_PARAM
));
//
PORTS
addInput
(createInput<as_PJ301MPort>(
Vec
(
10
,
217
),
module
,
VCA
::
ENV1_INPUT
));
addInput
(createInput<as_PJ301MPort>(
Vec
(
55
,
217
),
module
,
VCA
::
ENV2_INPUT
));
addInput
(createInput<as_PJ301MPort>(
Vec
(
10
,
260
),
module
,
VCA
::
IN1_INPUT
));
addInput
(createInput<as_PJ301MPort>(
Vec
(
55
,
260
),
module
,
VCA
::
IN2_INPUT
));
addOutput
(createOutput<as_PJ301MPortGold>(
Vec
(
10
,
310
),
module
,
VCA
::
OUT1_OUTPUT
));
addOutput
(createOutput<as_PJ301MPortGold>(
Vec
(
55
,
310
),
module
,
VCA
::
OUT2_OUTPUT
));
}
};
Model *modelVCA = createModel<
VCA
, VCAWidget>(
"
VCA
"
);
Back
|
FazBrowse Home
|
New Git URL