Skip to content

Commit 41599cc

Browse files
committed
Added sidechain pre-processing
1 parent 6ad1128 commit 41599cc

5 files changed

Lines changed: 256 additions & 48 deletions

File tree

include/private/meta/deesser.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,22 @@ namespace lsp
118118
static constexpr float LINKING_DFL = 100.0f;
119119
static constexpr float LINKING_STEP = 0.01f;
120120

121+
static constexpr float SC_LOOKAHEAD_MIN = 0.0f;
122+
static constexpr float SC_LOOKAHEAD_MAX = 20.0f;
123+
static constexpr float SC_LOOKAHEAD_DFL = 0.0f;
124+
static constexpr float SC_LOOKAHEAD_STEP = 0.01f;
125+
126+
static constexpr float SC_REACTIVITY_MIN = 0.000;
127+
static constexpr float SC_REACTIVITY_MAX = 50;
128+
static constexpr float SC_REACTIVITY_DFL = 10;
129+
static constexpr float SC_REACTIVITY_STEP = 0.0125;
130+
131+
static constexpr size_t SC_MODE_DFL = 1;
132+
static constexpr size_t SC_SOURCE_DFL = 0;
133+
static constexpr size_t SC_SOURCE_L_DFL = 2;
134+
static constexpr size_t SC_SOURCE_R_DFL = 3;
135+
static constexpr size_t SC_TYPE_DFL = 0;
136+
121137
static constexpr size_t FFT_MESH_POINTS = 640;
122138
static constexpr size_t CURVE_MESH_POINTS = 256;
123139
static constexpr size_t FFT_ANALYSIS_RANK = 13;

include/private/plugins/deesser.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <lsp-plug.in/dsp-units/util/Crossover.h>
3131
#include <lsp-plug.in/dsp-units/util/Delay.h>
3232
#include <lsp-plug.in/dsp-units/util/FFTCrossover.h>
33+
#include <lsp-plug.in/dsp-units/util/Sidechain.h>
3334
#include <lsp-plug.in/plug-fw/plug.h>
3435
#include <private/meta/deesser.h>
3536

@@ -77,6 +78,13 @@ namespace lsp
7778
CH_TOTAL
7879
};
7980

81+
enum sidechain_type_t
82+
{
83+
SCT_INTERNAL,
84+
SCT_EXTERNAL,
85+
SCT_LINK
86+
};
87+
8088
typedef struct premix_t
8189
{
8290
float fInToSc; // Input -> Sidechain mix
@@ -103,6 +111,22 @@ namespace lsp
103111
plug::IPort *pScToLink; // Sidechain -> Link mix
104112
} premix_t;
105113

114+
typedef struct sidechain_t
115+
{
116+
uint8_t nType; // Sidechain lookahead
117+
uint8_t nLookahead; // Sidechain lookahead
118+
bool bListen; // Sidechain listen
119+
120+
plug::IPort *pType; // Sidechain type
121+
plug::IPort *pMode; // Sidechain mode
122+
plug::IPort *pSource; // Sidechain source
123+
plug::IPort *pSplitScSource[2]; // Sidechain source in split mode
124+
plug::IPort *pLookahead; // Sidechain lookahead
125+
plug::IPort *pListen; // Sidechain listen
126+
plug::IPort *pReactivity; // Sidechain reactivity
127+
plug::IPort *pPreamp; // Sidechain pre-amplification
128+
} sidechain_t;
129+
106130
typedef struct crossover_t
107131
{
108132
uint32_t nMode; // Work mode
@@ -174,6 +198,7 @@ namespace lsp
174198
{
175199
// DSP processing modules
176200
dspu::Bypass sBypass; // Bypass
201+
dspu::Sidechain sSC; // Sidechain
177202
dspu::Equalizer sSCEq; // Sidechain equalizer
178203
dspu::Crossover sXOver; // Crossover
179204
dspu::FFTCrossover sFFTXOver; // FFT crossover
@@ -183,6 +208,7 @@ namespace lsp
183208
float *vScIn; // Sidechain signal
184209
float *vShmIn; // Shared memory link signal
185210

211+
float *vScBuffer; // Sidechain input buffer
186212
float *vBuffer; // Buffer for data
187213

188214
float fLoGain; // Gain of the lower frequency band
@@ -198,6 +224,7 @@ namespace lsp
198224
protected:
199225
size_t nChannels; // Number of channels
200226
channel_t *vChannels; // Delay channels
227+
float *vEmptyBuffer; // Empty buffer filled with zeros
201228
float *vBuffer; // Temporary buffer for audio processing
202229

203230
float fStereoLink; // Stereo linking
@@ -209,6 +236,7 @@ namespace lsp
209236
dspu::Compressor sCompressor; // Compressor for gain reduction
210237

211238
premix_t sPremix; // Premix settings
239+
sidechain_t sSC; // Sidechain setup
212240
analysis_t sAnalysis; // Analyzer parameters
213241
crossover_t sXOver; // Crossover settings
214242
preeq_t sPreEq; // Pre-equalization settings
@@ -226,10 +254,12 @@ namespace lsp
226254
static bool set_filter_params(dspu::Equalizer * eq, uint32_t index, const dspu::filter_params_t * fp);
227255
static void process_band(void *object, void *subject, size_t band, const float *data, size_t sample, size_t count);
228256
static size_t select_fft_rank(size_t sample_rate);
257+
static dspu::sidechain_source_t decode_sidechain_source(plug::IPort * src);
229258

230259
protected:
231260
void do_destroy();
232261
void update_premix();
262+
void update_sidechain();
233263
void update_analyzer();
234264
void update_preeq();
235265
void update_xover();
@@ -240,6 +270,8 @@ namespace lsp
240270
void output_xover_meshes();
241271
void output_reduction_meshes();
242272
void output_analysis_meshes();
273+
sidechain_type_t decode_sidechain_type(float value) const;
274+
inline float *select_buffer(channel_t & c);
243275

244276
public:
245277
explicit deesser(const meta::plugin_t *meta);

res/main/ui/plugins/dynamics/deesser.xml

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -705,58 +705,59 @@
705705
<!-- Sidechain overlay -->
706706
<overlay id="showsc" trigger="sidechain_trigger" hpos="1" vpos="1" halign="-1" valign="1" ipadding.t="4">
707707
<group text="groups.sidechain" vexpand="false" ipadding="0">
708-
<grid rows="5" cols="9" spacing="0" bg.color="bg_schema" height="139">
708+
<grid rows="4" cols="${(:stereo) ? 7 : 5}" spacing="0" bg.color="bg_schema" height="139">
709709
<!-- row 1 -->
710710
<ui:with pad.h="6" pad.v="4" fill="false" hexpand="true" width.min="56">
711711
<label text="labels.sc.preamp" vreduce="true"/>
712712
<label text="labels.sc.reactivity" vreduce="true"/>
713713
<label text="labels.sc.lookahead" vreduce="true"/>
714714
</ui:with>
715-
<cell rows="5" bg.color="bg" pad.h="2" hreduce="true"><vsep/></cell>
715+
<cell rows="4" bg.color="bg" pad.h="2" hreduce="true"><vsep/></cell>
716716
<label text="labels.setup" pad.h="6" pad.v="4" fill="false" vreduce="true"/>
717-
<cell rows="5" bg.color="bg" pad.h="2" hreduce="true"><vsep/></cell>
718-
<label text="labels.flt.HPF" pad.h="6" pad.v="4" fill="false" vreduce="true"/>
719-
<cell rows="5" bg.color="bg" pad.h="2" hreduce="true"><vsep/></cell>
720-
<label text="labels.flt.LPF" pad.h="6" pad.v="4" fill="false" vreduce="true"/>
721-
717+
<ui:if test=":stereo">
718+
<cell rows="4" bg.color="bg" pad.h="2" hreduce="true"><vsep/></cell>
719+
<label text="labels.source" pad.h="6" pad.v="4" fill="false" vreduce="true"/>
720+
</ui:if>
721+
722722
<!-- row 2 -->
723723
<ui:with bg.color="bg" pad.v="2" vreduce="true">
724724
<cell cols="3"><hsep/></cell>
725725
<hsep/>
726-
<hsep/>
727-
<hsep/>
726+
<ui:if test=":stereo">
727+
<hsep/>
728+
</ui:if>
728729
</ui:with>
729730

730731
<!-- row 3 -->
731-
<cell rows="2"><knob id="scp" scolor="kscale"/></cell>
732-
<cell rows="2"><knob id="scr" scolor="kscale"/></cell>
733-
<cell rows="2"><knob id="sla" scolor="kscale"/></cell>
734-
<cell rows="3">
732+
<knob id="scp" scolor="kscale"/>
733+
<knob id="scr" scolor="kscale"/>
734+
<knob id="sla" scolor="kscale"/>
735+
<cell rows="2">
735736
<vbox fill="false" spacing="1">
736737
<ui:with pad.h="6" pad.b="4" hfill="true">
737738
<combo id="sct" pad.t="4"/>
738739
<combo id="scm"/>
739-
<ui:if test=":stereo">
740-
<combo id="scs" visibility="!:ssplit"/>
741-
<combo id="sscs" visibility=":ssplit"/>
742-
</ui:if>
743740
<button id="scl" height="22" text="labels.listen" ui:inject="Button_cyan"/>
744741
</ui:with>
745742
</vbox>
746743
</cell>
747-
<combo id="shpm" pad.h="6" bright="(:shpm igt 0) ? 1 : 0.75" bg.bright="(:shpm igt 0) ? 1 : :const_bg_darken"/>
748-
<combo id="slpm" pad.h="6" bright="(:slpm igt 0) ? 1 : 0.75" bg.bright="(:slpm igt 0) ? 1 : :const_bg_darken"/>
749-
744+
<ui:if test=":stereo">
745+
<cell rows="2">
746+
<vbox fill="false" spacing="1">
747+
<ui:with pad.h="6" pad.b="4" hfill="true">
748+
<combo id="scs" visibility="!:ssplit"/>
749+
<combo id="sscl" visibility=":ssplit"/>
750+
<combo id="sscr" visibility=":ssplit"/>
751+
<button id="ssplit" text="labels.stereo_split" size="22" ui:inject="Button_blue" pad.h="2"/>
752+
</ui:with>
753+
</vbox>
754+
</cell>
755+
</ui:if>
756+
750757
<!-- row 4 -->
751-
<knob id="shpf" size="20" scolor="(:shpm igt 0) ? 'kscale' : 'cycle_inactive'" bg.bright="(:shpm igt 0) ? 1 : :const_bg_darken"/>
752-
<knob id="slpf" size="20" scolor="(:slpm igt 0) ? 'kscale' : 'cycle_inactive'" bg.bright="(:slpm igt 0) ? 1 : :const_bg_darken"/>
753-
754-
<!-- row 5 -->
755758
<value id="scp" sline="true" width.min="48"/>
756759
<value id="scr" sline="true"/>
757760
<value id="sla" sline="true"/>
758-
<value id="shpf" sline="true" bright="(:shpm igt 0) ? 1 : 0.75" bg.bright="(:shpm igt 0) ? 1 : :const_bg_darken"/>
759-
<value id="slpf" sline="true" bright="(:slpm igt 0) ? 1 : 0.75" bg.bright="(:slpm igt 0) ? 1 : :const_bg_darken"/>
760761
</grid>
761762
</group>
762763
</overlay>

src/main/meta/deesser.cpp

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,65 @@ namespace lsp
4343
// Plugin metadata
4444
static const port_item_t de_pf_filter_slope[] =
4545
{
46-
{ "off", "eq.slope.off" },
47-
{ "12 dB/oct", "eq.slope.12dbo" },
48-
{ "24 dB/oct", "eq.slope.24dbo" },
49-
{ "36 dB/oct", "eq.slope.36dbo" },
50-
{ "48 dB/oct", "eq.slope.48dbo" },
46+
{ "off", "eq.slope.off" },
47+
{ "12 dB/oct", "eq.slope.12dbo" },
48+
{ "24 dB/oct", "eq.slope.24dbo" },
49+
{ "36 dB/oct", "eq.slope.36dbo" },
50+
{ "48 dB/oct", "eq.slope.48dbo" },
5151
{ NULL, NULL }
5252
};
5353

5454
static const port_item_t de_split_modes[] =
5555
{
56-
{ "Classic", "deesser.modes.off" },
57-
{ "Classic", "deesser.modes.classic" },
58-
{ "Modern", "deesser.modes.modern" },
59-
{ "Linear Phase", "deesser.modes.linear_phase" },
56+
{ "Classic", "deesser.modes.off" },
57+
{ "Classic", "deesser.modes.classic" },
58+
{ "Modern", "deesser.modes.modern" },
59+
{ "Linear Phase", "deesser.modes.linear_phase" },
6060
{ NULL, NULL }
6161
};
6262

6363
static const port_item_t de_slopes[] =
6464
{
65-
{ "LR2 (12 dB/oct)", "deesser.slope.12dbo" },
66-
{ "LR4 (24 dB/oct)", "deesser.slope.24dbo" },
67-
{ "LR8 (48 dB/oct)", "deesser.slope.48dbo" },
65+
{ "LR2 (12 dB/oct)", "deesser.slope.12dbo" },
66+
{ "LR4 (24 dB/oct)", "deesser.slope.24dbo" },
67+
{ "LR8 (48 dB/oct)", "deesser.slope.48dbo" },
6868
{ NULL, NULL }
6969
};
7070

71+
static const port_item_t de_sc_type[] =
72+
{
73+
{ "Internal", "sidechain.internal" },
74+
{ "Link", "sidechain.link" },
75+
{ NULL, NULL }
76+
};
77+
78+
static const port_item_t de_sc2_type[] =
79+
{
80+
{ "Internal", "sidechain.internal" },
81+
{ "External", "sidechain.external" },
82+
{ "Link", "sidechain.link" },
83+
{ NULL, NULL }
84+
};
85+
86+
static const port_item_t de_sc_modes[] =
87+
{
88+
{ "Peak", "sidechain.peak" },
89+
{ "RMS", "sidechain.rms" },
90+
{ "LPF", "sidechain.lpf" },
91+
{ "SMA", "sidechain.sma" },
92+
{ NULL, NULL }
93+
};
94+
95+
static const port_item_t de_sc_sources[] =
96+
{
97+
{ "Middle", "sidechain.middle" },
98+
{ "Side", "sidechain.side" },
99+
{ "Left", "sidechain.left" },
100+
{ "Right", "sidechain.right" },
101+
{ "Min", "sidechain.min" },
102+
{ "Max", "sidechain.max" },
103+
{ NULL, NULL }
104+
};
71105

72106
#define DE_PREMIX \
73107
SWITCH("showpmx", "Show pre-mix overlay", "Show premix bar", 0.0f), \
@@ -138,12 +172,26 @@ namespace lsp
138172
LOG_CONTROL("knee", "Knee", "Knee", U_GAIN_AMP, deesser::KNEE), \
139173
MESH("curve", "Reduction curve", 2, deesser::CURVE_MESH_POINTS)
140174

175+
#define DE_SIDECHAIN_MONO_SOURCE
176+
#define DE_SIDECHAIN_STEREO_SOURCE \
177+
COMBO("scs", "Sidechain source", "SC source", deesser::SC_SOURCE_DFL, de_sc_sources), \
178+
COMBO("scsl", "Sidechain source L", "SC source L", deesser::SC_SOURCE_L_DFL, de_sc_sources), \
179+
COMBO("scsr", "Sidechain source R", "SC source R", deesser::SC_SOURCE_R_DFL, de_sc_sources),
180+
181+
#define DE_SIDECHAIN(sct, sct_dfl, sources) \
182+
SWITCH("showsc", "Show sidechain overlay", "Show SC bar", 0.0f), \
183+
COMBO("sct", "Sidechain type", "SC type", sct_dfl, sct), \
184+
COMBO("scm", "Sidechain mode", "SC mode", deesser::SC_MODE_DFL, de_sc_modes), \
185+
sources \
186+
CONTROL("sla", "Sidechain lookahead", "SC look", U_MSEC, deesser::SC_LOOKAHEAD), \
187+
SWITCH("scl", "Sidechain listen", "SC listen", 0.0f), \
188+
LOG_CONTROL("scr", "Sidechain reactivity", "SC react", U_MSEC, deesser::SC_REACTIVITY), \
189+
AMP_GAIN100("scp", "Sidechain preamp", "SC preamp", GAIN_AMP_0_DB)
141190

142191
#define DE_COMMON \
143192
BYPASS, \
144193
IN_GAIN, \
145194
OUT_GAIN, \
146-
SWITCH("showsc", "Show sidechain overlay", "Show SC bar", 0.0f), \
147195
LOG_CONTROL("zoom", "Graph zoom", "Zoom", U_GAIN_AMP, deesser::ZOOM)
148196

149197
#define DE_COMMON_MONO \
@@ -160,6 +208,7 @@ namespace lsp
160208
DE_SHM_LINK_MONO,
161209
DE_COMMON_MONO,
162210
DE_PREMIX,
211+
DE_SIDECHAIN(de_sc_type, 0, DE_SIDECHAIN_MONO_SOURCE),
163212
DE_ANALYSIS(1, DE_ANALYSIS_MONO),
164213
DE_CROSSOVER(1),
165214
DE_FILTERS,
@@ -174,6 +223,7 @@ namespace lsp
174223
DE_SHM_LINK_STEREO,
175224
DE_COMMON_STEREO,
176225
DE_PREMIX,
226+
DE_SIDECHAIN(de_sc_type, 0, DE_SIDECHAIN_STEREO_SOURCE),
177227
DE_ANALYSIS(2, DE_ANALYSIS_STEREO),
178228
DE_CROSSOVER(2),
179229
DE_FILTERS,
@@ -189,6 +239,7 @@ namespace lsp
189239
DE_SHM_LINK_MONO,
190240
DE_COMMON_MONO,
191241
DE_SC_PREMIX,
242+
DE_SIDECHAIN(de_sc2_type, 1, DE_SIDECHAIN_MONO_SOURCE),
192243
DE_ANALYSIS(1, DE_ANALYSIS_MONO),
193244
DE_CROSSOVER(1),
194245
DE_FILTERS,
@@ -204,6 +255,7 @@ namespace lsp
204255
DE_SHM_LINK_STEREO,
205256
DE_COMMON_STEREO,
206257
DE_SC_PREMIX,
258+
DE_SIDECHAIN(de_sc2_type, 1, DE_SIDECHAIN_STEREO_SOURCE),
207259
DE_ANALYSIS(2, DE_ANALYSIS_STEREO),
208260
DE_CROSSOVER(2),
209261
DE_FILTERS,

0 commit comments

Comments
 (0)