11/*
2- * Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3- * (C) 2023 Vladimir Sadovnikov <sadko4u@gmail.com>
2+ * Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+ * (C) 2025 Vladimir Sadovnikov <sadko4u@gmail.com>
44 *
55 * This file is part of lsp-plugins-mb-clipper
66 * Created on: 11 ноя 2023 г.
@@ -62,10 +62,11 @@ namespace lsp
6262 PF_ODP_ENABLED = 1 << 1 , // Overdrive protection enabled
6363 PF_LUFS_ENABLED = 1 << 2 , // Enable input LUFS limiter
6464 PF_CLIP_ENABLED = 1 << 3 , // Clipping enabled
65- PF_DIRTY_BAND = 1 << 4 , // Update band filter curve
66- PF_SYNC_BAND = 1 << 5 , // Sync band filter curve
67- PF_SYNC_ODP = 1 << 6 , // Sync overdrive protection curve
68- PF_SYNC_CLIP = 1 << 7 , // Sync sigmoid clipping curve
65+ PF_DC_COMPENSATE = 1 << 4 , // DC compensate
66+ PF_DIRTY_BAND = 1 << 5 , // Update band filter curve
67+ PF_SYNC_BAND = 1 << 6 , // Sync band filter curve
68+ PF_SYNC_ODP = 1 << 7 , // Sync overdrive protection curve
69+ PF_SYNC_CLIP = 1 << 8 , // Sync sigmoid clipping curve
6970
7071 PF_SYNC_ALL = PF_SYNC_BAND | PF_SYNC_ODP | PF_SYNC_CLIP
7172 };
@@ -84,8 +85,9 @@ namespace lsp
8485 GF_OUT_CLIP = 1 << 3 , // Output clipper enabled
8586 GF_ODP_ENABLED = 1 << 4 , // Overdrive protection enabled
8687 GF_CLIP_ENABLED = 1 << 5 , // Clipping enabled
87- GF_SYNC_ODP = 1 << 6 , // Sync overdrive protection curve
88- GF_SYNC_CLIP = 1 << 7 , // Sync sigmoid clipping curve
88+ GF_DC_COMPENSATE = 1 << 6 , // DC compensate
89+ GF_SYNC_ODP = 1 << 7 , // Sync overdrive protection curve
90+ GF_SYNC_CLIP = 1 << 8 , // Sync sigmoid clipping curve
8991
9092 GF_SYNC_ALL = GF_SYNC_ODP | GF_SYNC_CLIP
9193 };
@@ -114,13 +116,16 @@ namespace lsp
114116 {
115117 dspu::sigmoid::function_t pFunc; // Sigmoid function
116118 float fThreshold ; // Threshold
119+ float fDCOffset ; // DC offset
117120 float fPumping ; // Pumping
118121 float fScaling ; // Sigmoid scaling
119122 float fKnee ; // Knee
120123
121124 plug::IPort *pOn; // Enable sigmoid function
122125 plug::IPort *pFunction; // Sigmoid function
123126 plug::IPort *pThreshold; // Sigmoid threshold
127+ plug::IPort *pDCOffset; // DC offset
128+ plug::IPort *pDCCompensate; // DC compensate
124129 plug::IPort *pPumping; // Sigmoid pumping
125130 plug::IPort *pCurveMesh; // Curve chart mesh
126131 } clip_params_t ;
@@ -134,6 +139,8 @@ namespace lsp
134139 dspu::Delay sPostDelay ; // Signal post-delay
135140 dspu::MeterGraph sInGraph ; // Input meter graph
136141 dspu::MeterGraph sOutGraph ; // Output meter graph
142+ dspu::MeterGraph sWaveformGraph ; // Waveform graph
143+ dspu::MeterGraph sRedGraph ; // Gain reduction graph
137144
138145 float *vInData; // Input data buffer
139146 float *vData; // Data buffer
@@ -146,8 +153,8 @@ namespace lsp
146153 float fOdpOut ; // Overdrive protection out level
147154 float fOdpRed ; // Overdrive protection reduction level
148155
149- float fClipIn ; // Clipping input level measured
150- float fClipOut ; // Clipping output level measured
156+ float fClipIn [ 2 ]; // Clipping input level measured
157+ float fClipOut [ 2 ]; // Clipping output level measured
151158 float fClipRed ; // Clipping reduction level measured
152159
153160 plug::IPort *pIn; // Input level meter
@@ -158,11 +165,9 @@ namespace lsp
158165 plug::IPort *pOdpOut; // ODP output level meter
159166 plug::IPort *pOdpRed; // ODP reduction level meter
160167
161- plug::IPort *pClipIn; // Clipping input level meter
162- plug::IPort *pClipOut; // Clipping output level meter
168+ plug::IPort *pClipIn[ 2 ]; // Clipping input level meter
169+ plug::IPort *pClipOut[ 2 ]; // Clipping output level meter
163170 plug::IPort *pClipRed; // Clipping reduction level meter
164-
165- plug::IPort *pTimeMesh; // Input, output and gain reduction graph mesh
166171 } band_t ;
167172
168173 typedef struct lufs_limiter_t
@@ -221,6 +226,8 @@ namespace lsp
221226 dspu::Dither sDither ; // Dither
222227 dspu::MeterGraph sInGraph ; // Input meter graph
223228 dspu::MeterGraph sOutGraph ; // Output meter graph
229+ dspu::MeterGraph sRedGraph ; // Gain reduction graph
230+ dspu::MeterGraph sWaveformGraph ; // Waveform graph
224231 band_t vBands[meta::mb_clipper::BANDS_MAX ]; // Bands for processing
225232
226233 uint32_t nAnInChannel; // Analyzer input channel
@@ -239,13 +246,14 @@ namespace lsp
239246 float fOdpOut ; // Overdrive protection out level
240247 float fOdpRed ; // Overdrive protection reduction level
241248
242- float fClipIn ; // Clipping input level measured
243- float fClipOut ; // Clipping output level measured
249+ float fClipIn [ 2 ]; // Clipping input level measured
250+ float fClipOut [ 2 ]; // Clipping output level measured
244251 float fClipRed ; // Clipping reduction level measured
245252
246253 // Buffers
247254 float *vIn; // Input buffer
248255 float *vOut; // Output buffer
256+ float *vInData; // Input data buffer for metering
249257 float *vData; // Data buffer
250258 float *vSc; // Sidechain buffer
251259 float *vTr; // Transfer function
@@ -272,24 +280,30 @@ namespace lsp
272280 plug::IPort *pOdpOut; // ODP output level meter
273281 plug::IPort *pOdpRed; // ODP reduction level meter
274282
275- plug::IPort *pClipIn; // Clipping input level meter
276- plug::IPort *pClipOut; // Clipping output level meter
283+ plug::IPort *pClipIn[ 2 ]; // Clipping input level meter
284+ plug::IPort *pClipOut[ 2 ]; // Clipping output level meter
277285 plug::IPort *pClipRed; // Clipping reduction level meter
286+ } channel_t ;
278287
288+ typedef struct graph_t
289+ {
279290 plug::IPort *pTimeMesh; // Input, output and gain reduction graph mesh
280- } channel_t ;
291+ plug::IPort *pWaveformMesh; // Oscillogram mesh
292+ } graph_t ;
281293
282294 static dspu::sigmoid::function_t vSigmoidFunctions[];
283295
284296 protected:
285297 size_t nChannels; // Number of channels
286- channel_t *vChannels; // Delay channels
298+ channel_t *vChannels; // Processing channels
287299
288300 dspu::Analyzer sAnalyzer ; // FFT analyzer
289301 dspu::Counter sCounter ; // Counter
290302 dspu::LoudnessMeter sOutMeter ; // Output LUFS meter
291303 split_t vSplits[meta::mb_clipper::BANDS_MAX -1 ];
292- processor_t vProc[meta::mb_clipper::BANDS_MAX ]; // Processor
304+ processor_t vProc[meta::mb_clipper::BANDS_MAX ]; // Processor
305+ graph_t vBGraph[meta::mb_clipper::BANDS_MAX ]; // Band Graphs
306+ graph_t sGraph ; // Output graphs
293307 compressor_t sComp ; // Simple compressor
294308 odp_params_t sOdp ; // Overdrive protection params
295309 clip_params_t sClip ; // Clipping parameters
@@ -313,6 +327,7 @@ namespace lsp
313327 float *vLinSigmoid; // Linear scale for sigmoid
314328 float *vLogSigmoid; // Logarithmic scale for sigmoid
315329 float *vTime; // Time graph
330+ float *vWaveformTime; // Waveform time graph
316331 core::IDBuffer *pIDisplay; // Inline display buffer
317332
318333 plug::IPort *pBypass; // Bypass
@@ -369,20 +384,26 @@ namespace lsp
369384 static void dump (dspu::IStateDumper *v, const char *name, const odp_params_t *p);
370385 static void dump (dspu::IStateDumper *v, const char *name, const clip_params_t *p);
371386 static void dump (dspu::IStateDumper *v, const char *name, const lufs_limiter_t *l);
387+ static void dump (dspu::IStateDumper *v, const char *name, const graph_t *g);
372388
373389 protected:
374390 void do_destroy ();
375391 void bind_input_buffers ();
376392 void limit_input_loudness (size_t samples);
377393 void split_bands (size_t samples);
394+ void process_clip_channel (channel_t *c, size_t samples);
395+ void process_clip_band (band_t *b, processor_t *p, size_t samples);
378396 void process_bands (size_t samples);
379397 void process_output_clipper (size_t samples);
398+ void meter_band (band_t *b, size_t samples);
399+ void meter_channel (channel_t *c, size_t samples);
380400 void perform_analysis (size_t samples);
381401 void output_signal (size_t samples);
382402 void advance_buffers (size_t samples);
383403 void merge_bands (size_t samples);
384404 void output_meters ();
385405 void output_mesh_curves (size_t samples);
406+ void output_mesh_graphs (size_t samples);
386407
387408 public:
388409 explicit mb_clipper (const meta::plugin_t *meta);
0 commit comments