1 /*
2  * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3  *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4  *
5  * This file is part of lsp-plugins
6  * Created on: 24 нояб. 2016 г.
7  *
8  * lsp-plugins is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * any later version.
12  *
13  * lsp-plugins is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #include <core/types.h>
23 #include <metadata/plugins.h>
24 #include <metadata/ports.h>
25 #include <metadata/developers.h>
26 
27 namespace lsp
28 {
29     //-------------------------------------------------------------------------
30     // Limiter
31     static const int limiter_classes[] = { C_LIMITER, -1 };
32 
33     static port_item_t limiter_oper_modes[] =
34     {
35         { "Herm Thin",      "limiter.herm_thin" },
36         { "Herm Wide",      "limiter.herm_wide" },
37         { "Herm Tail",      "limiter.herm_tail" },
38         { "Herm Duck",      "limiter.herm_duck" },
39 
40         { "Exp Thin",       "limiter.exp_thin" },
41         { "Exp Wide",       "limiter.exp_wide" },
42         { "Exp Tail",       "limiter.exp_tail" },
43         { "Exp Duck",       "limiter.exp_duck" },
44 
45         { "Line Thin",      "limiter.line_thin" },
46         { "Line Wide",      "limiter.line_wide" },
47         { "Line Tail",      "limiter.line_tail" },
48         { "Line Duck",      "limiter.line_duck" },
49 
50         { NULL, NULL }
51     };
52 
53     static port_item_t limiter_ovs_modes[] =
54     {
55         { "None",           "oversampler.none" },
56 
57         { "Half x2(2L)",    "oversampler.half.2x2" },
58         { "Half x2(3L)",    "oversampler.half.2x3" },
59         { "Half x3(2L)",    "oversampler.half.3x2" },
60         { "Half x3(3L)",    "oversampler.half.3x3" },
61         { "Half x4(2L)",    "oversampler.half.4x2" },
62         { "Half x4(3L)",    "oversampler.half.4x3" },
63         { "Half x6(2L)",    "oversampler.half.6x2" },
64         { "Half x6(3L)",    "oversampler.half.6x3" },
65         { "Half x8(2L)",    "oversampler.half.8x2" },
66         { "Half x8(3L)",    "oversampler.half.8x3" },
67 
68         { "Full x2(2L)",    "oversampler.full.2x2" },
69         { "Full x2(3L)",    "oversampler.full.2x3" },
70         { "Full x3(2L)",    "oversampler.full.3x2" },
71         { "Full x3(3L)",    "oversampler.full.3x3" },
72         { "Full x4(2L)",    "oversampler.full.4x2" },
73         { "Full x4(3L)",    "oversampler.full.4x3" },
74         { "Full x6(2L)",    "oversampler.full.6x2" },
75         { "Full x6(3L)",    "oversampler.full.6x3" },
76         { "Full x8(2L)",    "oversampler.full.8x2" },
77         { "Full x8(3L)",    "oversampler.full.8x3" },
78 
79         { NULL, NULL }
80     };
81 
82     static port_item_t limiter_dither_modes[] =
83     {
84         { "None",   "dither.none" },
85         { "7bit",   "dither.bits.7" },
86         { "8bit",   "dither.bits.8" },
87         { "11bit",  "dither.bits.11" },
88         { "12bit",  "dither.bits.12" },
89         { "15bit",  "dither.bits.15" },
90         { "16bit",  "dither.bits.16" },
91         { "23bit",  "dither.bits.23" },
92         { "24bit",  "dither.bits.24" },
93         { NULL, NULL }
94     };
95 
96     #define LIMIT_COMMON    \
97         BYPASS,             \
98         IN_GAIN,            \
99         OUT_GAIN,           \
100         AMP_GAIN100("scp", "Sidechain preamp", GAIN_AMP_0_DB), \
101         SWITCH("alr", "Automatic level regulation", 1.0f), \
102         LOG_CONTROL("alr_at", "Automatic level regulation attack time", U_MSEC, limiter_base_metadata::ALR_ATTACK_TIME), \
103         LOG_CONTROL("alr_rt", "Automatic level regulation release time", U_MSEC, limiter_base_metadata::ALR_RELEASE_TIME), \
104         COMBO("mode", "Operating mode", limiter_base_metadata::LOM_DEFAULT, limiter_oper_modes), \
105         LOG_CONTROL("th", "Threshold", U_GAIN_AMP, limiter_base_metadata::THRESHOLD), \
106         LOG_CONTROL("knee", "Knee", U_GAIN_AMP, limiter_base_metadata::KNEE), \
107         SWITCH("boost", "Gain boost", 1.0f), \
108         LOG_CONTROL("lk", "Lookahead", U_MSEC, limiter_base_metadata::LOOKAHEAD), \
109         LOG_CONTROL("at", "Attack time", U_MSEC, limiter_base_metadata::ATTACK_TIME), \
110         LOG_CONTROL("rt", "Release time", U_MSEC, limiter_base_metadata::RELEASE_TIME), \
111         COMBO("ovs", "Oversampling", limiter_base_metadata::OVS_DEFAULT, limiter_ovs_modes),           \
112         COMBO("dith", "Dithering", limiter_base_metadata::DITHER_DEFAULT, limiter_dither_modes),           \
113         SWITCH("pause", "Pause graph analysis", 0.0f), \
114         TRIGGER("clear", "Clear graph analysis")
115 
116     #define LIMIT_COMMON_SC \
117         SWITCH("extsc", "External sidechain", 0.0f)
118 
119     #define LIMIT_COMMON_MONO       \
120         LIMIT_COMMON
121     #define LIMIT_COMMON_STEREO     \
122         LIMIT_COMMON_MONO, \
123         LOG_CONTROL("slink", "Stereo linking", U_PERCENT, limiter_base_metadata::LINKING)
124 
125     #define LIMIT_COMMON_SC_MONO    \
126         LIMIT_COMMON, \
127         LIMIT_COMMON_SC
128 
129     #define LIMIT_COMMON_SC_STEREO  \
130         LIMIT_COMMON_STEREO, \
131         LIMIT_COMMON_SC
132 
133     #define LIMIT_METERS(id, label) \
134         SWITCH("igv" id, "Input graph visibility" label, 1.0f), \
135         SWITCH("ogv" id, "Output graph visibility" label, 1.0f), \
136         SWITCH("scgv" id, "Sidechain graph visibility" label, 1.0f), \
137         SWITCH("grgv" id, "Gain graph visibility" label, 1.0f), \
138         METER_OUT_GAIN("ilm" id, "Input level meter" label, GAIN_AMP_0_DB), \
139         METER_OUT_GAIN("olm" id, "Output level meter" label, GAIN_AMP_0_DB), \
140         METER_OUT_GAIN("sclm" id, "Sidechain level meter" label, GAIN_AMP_0_DB), \
141         METER_GAIN_DFL("grlm" id, "Gain reduction level meter" label, GAIN_AMP_0_DB, GAIN_AMP_0_DB), \
142         MESH("ig" id, "Input graph" label, 2, limiter_base_metadata::HISTORY_MESH_SIZE), \
143         MESH("og" id, "Output graph" label, 2, limiter_base_metadata::HISTORY_MESH_SIZE), \
144         MESH("scg" id, "Sidechain graph" label, 2, limiter_base_metadata::HISTORY_MESH_SIZE), \
145         MESH("grg" id, "Gain graph" label, 2, limiter_base_metadata::HISTORY_MESH_SIZE)
146 
147     #define LIMIT_METERS_MONO       LIMIT_METERS("", "")
148     #define LIMIT_METERS_STEREO     LIMIT_METERS("_l", " Left"), LIMIT_METERS("_r", " Right")
149 
150     static const port_t limiter_mono_ports[] =
151     {
152         PORTS_MONO_PLUGIN,
153         LIMIT_COMMON_MONO,
154         LIMIT_METERS_MONO,
155 
156         PORTS_END
157     };
158 
159     static const port_t limiter_stereo_ports[] =
160     {
161         PORTS_STEREO_PLUGIN,
162         LIMIT_COMMON_STEREO,
163         LIMIT_METERS_STEREO,
164 
165         PORTS_END
166     };
167 
168     static const port_t sc_limiter_mono_ports[] =
169     {
170         PORTS_MONO_PLUGIN,
171         PORTS_MONO_SIDECHAIN,
172         LIMIT_COMMON_SC_MONO,
173         LIMIT_METERS_MONO,
174 
175         PORTS_END
176     };
177 
178     static const port_t sc_limiter_stereo_ports[] =
179     {
180         PORTS_STEREO_PLUGIN,
181         PORTS_STEREO_SIDECHAIN,
182         LIMIT_COMMON_SC_STEREO,
183         LIMIT_METERS_STEREO,
184 
185         PORTS_END
186     };
187 
188     // Limiter
189     const plugin_metadata_t  limiter_mono_metadata::metadata =
190     {
191         "Begrenzer Mono",
192         "Limiter Mono",
193         "B1M",
194         &developers::v_sadovnikov,
195         "limiter_mono",
196         "jz5z",
197         LSP_LIMITER_BASE + 0,
198         LSP_VERSION(1, 0, 2),
199         limiter_classes,
200         E_INLINE_DISPLAY | E_DUMP_STATE,
201         limiter_mono_ports,
202         "dynamics/limiter/single/mono.xml",
203         NULL,
204         mono_plugin_port_groups
205     };
206 
207     const plugin_metadata_t  limiter_stereo_metadata::metadata =
208     {
209         "Begrenzer Stereo",
210         "Limiter Stereo",
211         "B1S",
212         &developers::v_sadovnikov,
213         "limiter_stereo",
214         "rfuc",
215         LSP_LIMITER_BASE + 1,
216         LSP_VERSION(1, 0, 2),
217         limiter_classes,
218         E_INLINE_DISPLAY | E_DUMP_STATE,
219         limiter_stereo_ports,
220         "dynamics/limiter/single/stereo.xml",
221         NULL,
222         stereo_plugin_port_groups
223     };
224 
225     const plugin_metadata_t  sc_limiter_mono_metadata::metadata =
226     {
227         "Sidechain-Begrenzer Mono",
228         "Sidechain Limiter Mono",
229         "SCB1M",
230         &developers::v_sadovnikov,
231         "sc_limiter_mono",
232         "kyzu",
233         LSP_LIMITER_BASE + 2,
234         LSP_VERSION(1, 0, 2),
235         limiter_classes,
236         E_INLINE_DISPLAY | E_DUMP_STATE,
237         sc_limiter_mono_ports,
238         "dynamics/limiter/single/mono.xml",
239         NULL,
240         mono_plugin_sidechain_port_groups
241     };
242 
243     const plugin_metadata_t  sc_limiter_stereo_metadata::metadata =
244     {
245         "Sidechain-Begrenzer Stereo",
246         "Sidechain Limiter Stereo",
247         "SCB1S",
248         &developers::v_sadovnikov,
249         "sc_limiter_stereo",
250         "zwf7",
251         LSP_LIMITER_BASE + 3,
252         LSP_VERSION(1, 0, 2),
253         limiter_classes,
254         E_INLINE_DISPLAY | E_DUMP_STATE,
255         sc_limiter_stereo_ports,
256         "dynamics/limiter/single/stereo.xml",
257         NULL,
258         stereo_plugin_sidechain_port_groups
259     };
260 }
261 
262 
263