-
Notifications
You must be signed in to change notification settings - Fork 21
/
DropDsp.cpp
executable file
·160 lines (108 loc) · 3.34 KB
/
DropDsp.cpp
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*****************************************************************************
DropDsp.cpp
Copyright (c) 2020 Raphael DINGE
*Tab=3***********************************************************************/
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include "DropDsp.h"
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*
==============================================================================
Name : ctor
==============================================================================
*/
DropDsp::DropDsp (float sample_freq)
{
for (auto & filter : _filters)
{
filter.set_sample_freq (sample_freq);
filter.set_type_high_pass ();
}
}
/*
==============================================================================
Name : toggle_arm
==============================================================================
*/
void DropDsp::toggle_arm ()
{
_arm_active = !_arm_active;
}
/*
==============================================================================
Name : tick
==============================================================================
*/
void DropDsp::sync ()
{
_active.target = float (_arm_active);
}
/*
==============================================================================
Name : set_mode
==============================================================================
*/
void DropDsp::set_mode (Mode mode)
{
_mode.target = float (mode == Mode::Mute);
}
/*
==============================================================================
Name : set_highpass_freq
==============================================================================
*/
void DropDsp::set_highpass_freq (float freq)
{
for (auto & filter : _filters) filter.set_freq (freq);
}
/*
==============================================================================
Name : process
==============================================================================
*/
void DropDsp::process (float * const out [], const float * const in [], std::size_t size)
{
for (auto & filter : _filters) filter.update ();
for (std::size_t i = 0 ; i < size ; ++i)
{
_active.process ();
_mode.process ();
for (std::size_t c = 0 ; c < NBR_CHANNELS ; ++c)
{
auto & filter = _filters [c];
auto in_chn = in [c];
auto out_chn = out [c];
float in_spl = in_chn [i];
float & out_spl = out_chn [i];
auto hp = filter.process (in_spl);
auto mix = hp * (1.f - _mode);
out_spl = in_spl + (mix - in_spl) * _active;
}
}
}
/*
==============================================================================
Name : state
==============================================================================
*/
DropDsp::State DropDsp::state ()
{
if (_active.target == float (_arm_active))
{
if (_active.target == 0.f)
{
return State::Off;
}
else
{
return State::Active;
}
}
else
{
return State::Armed;
}
}
/*\\\ INTERNAL \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/