Skip to content

Commit 72c81dd

Browse files
committed
Release 1.0.31
* Updated and extended interface of dspu::RingBuffer. * Optimizations: dspu::MeterGraph now uses dspu::RingBuffer instead of dsp::ShiftBuffer. * Added support of infiniter LUFS measurement period by dspu::ILUFSMeter. * Added dspu::PeakMeter class for managing peak values. * Fixed crash in dspu::SpectralProcessor::clear method. * Updated module versions in dependencies.
2 parents 1063cf2 + d2af9b4 commit 72c81dd

File tree

17 files changed

+735
-160
lines changed

17 files changed

+735
-160
lines changed

CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
* RECENT CHANGES
33
*******************************************************************************
44

5+
=== 1.0.31 ===
6+
* Updated and extended interface of dspu::RingBuffer.
7+
* Optimizations: dspu::MeterGraph now uses dspu::RingBuffer instead of dsp::ShiftBuffer.
8+
* Added support of infiniter LUFS measurement period by dspu::ILUFSMeter.
9+
* Added dspu::PeakMeter class for managing peak values.
10+
* Fixed crash in dspu::SpectralProcessor::clear method.
11+
* Updated module versions in dependencies.
12+
513
=== 1.0.30 ===
614
* Added MM_PEAK algorithm to MeterGraph and ScaledMeterGraph.
715
* Spectrum analyzer now allows to read linear-scaled frequencies and indices.

include/lsp-plug.in/dsp-units/const.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
#define LSP_PLUG_IN_DSP_UNITS_CONST_H_
2424

2525
#define LSP_DSP_UNITS_DEFAULT_SAMPLE_RATE 48000 /* Default sample rate */
26-
#define LSP_DSP_UNITS_AIR_ADIABATIC_INDEX 1.4 /* Adiabatic index for the Air */
27-
#define LSP_DSP_UNITS_AIR_MOLAR_MASS 28.98 /* Molar mass of the air [g/mol] */
28-
#define LSP_DSP_UNITS_GAS_CONSTANT 8.3144598 /* Gas constant [ j/(mol * K) } */
29-
#define LSP_DSP_UNITS_TEMP_ABS_ZERO -273.15 /* Temperature of the absolute zero [ C ] */
26+
#define LSP_DSP_UNITS_AIR_ADIABATIC_INDEX 1.4f /* Adiabatic index for the Air */
27+
#define LSP_DSP_UNITS_AIR_MOLAR_MASS 28.98f /* Molar mass of the air [g/mol] */
28+
#define LSP_DSP_UNITS_GAS_CONSTANT 8.3144598f /* Gas constant [ j/(mol * K) } */
29+
#define LSP_DSP_UNITS_TEMP_ABS_ZERO -273.15f /* Temperature of the absolute zero [ C ] */
3030
#define LSP_DSP_UNITS_SPEC_FREQ_MIN 10.0f /* Minimum frequency range [ Hz ] */
3131
#define LSP_DSP_UNITS_SPEC_FREQ_MAX 24000.0f /* Maximum frequency range [ Hz ] */
3232
#define LSP_DSP_UNITS_SOUND_SPEED_M_S 340.29f /* The default sound speed [ m / s ] */

include/lsp-plug.in/dsp-units/meters/ILUFSMeter.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2024 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-dsp-units
66
* Created on: 16 нояб. 2024 г.
@@ -61,6 +61,7 @@ namespace lsp
6161
{
6262
F_UPD_FILTERS = 1 << 0,
6363
F_UPD_TIME = 1 << 1,
64+
F_BLK_FULL = 1 << 2,
6465

6566
F_UPD_ALL = F_UPD_FILTERS | F_UPD_TIME
6667
};
@@ -96,8 +97,8 @@ namespace lsp
9697
uint32_t nBlockPart; // The index of the current value to update in the gating block
9798
uint32_t nMSSize; // Overall number of blocks available in buffer
9899
uint32_t nMSHead; // Current position to write new block to buffer
99-
int32_t nMSInt; // Number of blocks to integrate
100-
int32_t nMSCount; // Count of processed blocks
100+
uint32_t nMSInt; // Number of blocks to integrate
101+
uint32_t nMSCount; // Count of processed block parts
101102

102103
uint32_t nSampleRate; // Sample rate
103104
uint32_t nChannels; // Number of channels
@@ -136,7 +137,9 @@ namespace lsp
136137
status_t init(size_t channels, float max_int_time = 60, float block_period = dspu::bs::LUFS_MEASURE_PERIOD_MS);
137138

138139
private:
139-
float compute_gated_loudness(float threshold);
140+
float compute_gated_loudness(float threshold) const;
141+
inline float compute_infinite_loudness(float threshold) const;
142+
void clear_block_buffers();
140143

141144
public:
142145
/**
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <[email protected]>
4+
*
5+
* This file is part of lsp-dsp-units
6+
* Created on: 4 окт. 2025 г.
7+
*
8+
* lsp-dsp-units 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-dsp-units 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-dsp-units. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
#ifndef LSP_PLUG_IN_DSP_UNITS_CTL_PEAK_H_
23+
#define LSP_PLUG_IN_DSP_UNITS_CTL_PEAK_H_
24+
25+
#include <lsp-plug.in/dsp-units/version.h>
26+
#include <lsp-plug.in/dsp-units/iface/IStateDumper.h>
27+
28+
namespace lsp
29+
{
30+
namespace dspu
31+
{
32+
/**
33+
* Simple peak monitor. Detects peak and holds it for desired period
34+
*/
35+
class LSP_DSP_UNITS_PUBLIC PeakMeter
36+
{
37+
protected:
38+
float fPeak; // Current value
39+
float fTau; // Time coefficient
40+
float fHold; // Hold time in milliseconds
41+
float fRelease; // Release time in milliseconds
42+
uint32_t nHold; // Hold time in samples
43+
uint32_t nCounter; // Hold time counter
44+
uint32_t nSampleRate;// Sample rate
45+
bool bUpdate; // Update flag
46+
47+
protected:
48+
void update_settings();
49+
50+
public:
51+
explicit PeakMeter();
52+
PeakMeter(const PeakMeter &) = delete;
53+
PeakMeter(PeakMeter &&) = delete;
54+
~PeakMeter();
55+
PeakMeter & operator = (const PeakMeter &) = delete;
56+
PeakMeter & operator = (PeakMeter &&) = delete;
57+
58+
/**
59+
* Construct object
60+
*/
61+
void construct();
62+
63+
/**
64+
* Destroy object
65+
*/
66+
void destroy();
67+
68+
public:
69+
/**
70+
* Update current sample rate
71+
*
72+
* @param sample_rate current sample rate
73+
*/
74+
void set_sample_rate(size_t sample_rate);
75+
76+
/**
77+
* Get current sample rate
78+
* @return current sample rate
79+
*/
80+
size_t sample_rate() const;
81+
82+
/**
83+
* Process the signal
84+
* @param data input signal
85+
* @param count number of samples to process
86+
* @return current peak value
87+
*/
88+
float process(const float *data, size_t count);
89+
90+
/**
91+
* Process the signal
92+
* @param dst destination buffer to store peak value
93+
* @param src input signal
94+
* @param count number of samples to process
95+
* @return current peak value
96+
*/
97+
float process(float *dst, const float *src, size_t count);
98+
99+
/**
100+
* Process the single sample
101+
* @param data input sample
102+
* @param count number of samples to consider being processed
103+
* @return current peak value
104+
*/
105+
float process(float value, size_t count);
106+
107+
/**
108+
* Set hold time
109+
* @param value hold time in milliseconds
110+
*/
111+
void set_hold_time(float value);
112+
113+
/**
114+
* Get hold time
115+
* @return hold time in milliseconds
116+
*/
117+
float hold_time() const;
118+
119+
/**
120+
* Set release time
121+
* @param value release time in milliseconds
122+
*/
123+
void set_release_time(float value);
124+
125+
/**
126+
* Get release time
127+
* @return release time release time in milliseconds
128+
*/
129+
float release_time() const;
130+
131+
/**
132+
* Set hold and release time
133+
* @param hold hold time in milliseconds
134+
* @param release release time in milliseconds
135+
*/
136+
void set_time(float hold, float release);
137+
138+
/**
139+
* Get the current peak value
140+
* @return current peak value
141+
*/
142+
float value() const;
143+
144+
/**
145+
* Cleanup current peak, set to 0.
146+
*/
147+
void clear();
148+
149+
/**
150+
* Dump the state
151+
* @param v state dumper
152+
*/
153+
void dump(IStateDumper *v) const;
154+
};
155+
} /* namespace dspu */
156+
} /* namespace lsp */
157+
158+
159+
160+
#endif /* LSP_PLUG_IN_DSP_UNITS_CTL_PEAK_H_ */

include/lsp-plug.in/dsp-units/units.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ namespace lsp
136136
*/
137137
inline float db_to_gain(float db)
138138
{
139-
return expf(db * M_LN10 * 0.05f);
139+
return expf(db * float(M_LN10) * 0.05f);
140140
}
141141

142142
/** Convert decibels to power value
@@ -146,7 +146,7 @@ namespace lsp
146146
*/
147147
inline float db_to_power(float db)
148148
{
149-
return expf(db * M_LN10 * 0.1f);
149+
return expf(db * float(M_LN10) * 0.1f);
150150
}
151151

152152
/** Convert decibels to nepers
@@ -166,7 +166,7 @@ namespace lsp
166166
*/
167167
inline float db_to_lufs(float db)
168168
{
169-
return db - 0.691;
169+
return db - 0.691f;
170170
}
171171

172172
/** Convert gain value to decibels
@@ -176,7 +176,7 @@ namespace lsp
176176
*/
177177
inline float gain_to_db(float gain)
178178
{
179-
return (20.0f / M_LN10) * logf(gain);
179+
return (20.0f / float(M_LN10)) * logf(gain);
180180
}
181181

182182
/** Convert powerr value to decibels
@@ -186,7 +186,7 @@ namespace lsp
186186
*/
187187
inline float power_to_db(float pwr)
188188
{
189-
return (10.0f / M_LN10) * logf(pwr);
189+
return (10.0f / float(M_LN10)) * logf(pwr);
190190
}
191191

192192
/**
@@ -196,7 +196,7 @@ namespace lsp
196196
*/
197197
inline float gain_to_lufs(float gain)
198198
{
199-
return (20.0f / M_LN10) * logf(gain) - 0.691f;
199+
return (20.0f / float(M_LN10)) * logf(gain) - 0.691f;
200200
}
201201

202202
/**
@@ -206,7 +206,7 @@ namespace lsp
206206
*/
207207
inline float lufs_to_gain(float lufs)
208208
{
209-
return expf((lufs + 0.691f) * M_LN10 * 0.05f);
209+
return expf((lufs + 0.691f) * float(M_LN10) * 0.05f);
210210
}
211211

212212
/** Convert LKFS/LUFS to power value
@@ -216,7 +216,7 @@ namespace lsp
216216
*/
217217
inline float lufs_to_power(float lufs)
218218
{
219-
return expf((lufs + 0.691f) * M_LN10 * 0.1f);
219+
return expf((lufs + 0.691f) * float(M_LN10) * 0.1f);
220220
}
221221

222222
/** Convert LKFS/LUFS to nepers
@@ -236,7 +236,7 @@ namespace lsp
236236
*/
237237
inline float lufs_to_db(float lufs)
238238
{
239-
return lufs + 0.691;
239+
return lufs + 0.691f;
240240
}
241241

242242
/**
@@ -246,7 +246,7 @@ namespace lsp
246246
*/
247247
inline float gain_to_lu(float gain)
248248
{
249-
return (20.0f / M_LN10) * logf(gain) + 22.309f;
249+
return (20.0f / float(M_LN10)) * logf(gain) + 22.309f;
250250
}
251251

252252
/**
@@ -256,7 +256,7 @@ namespace lsp
256256
*/
257257
inline float lu_to_gain(float lu)
258258
{
259-
return expf((lu - 22.309f) * M_LN10 * 0.05f);
259+
return expf((lu - 22.309f) * float(M_LN10) * 0.05f);
260260
}
261261

262262
/** Convert nepers to gain value
@@ -326,7 +326,7 @@ namespace lsp
326326
*/
327327
inline float semitones_to_frequency_shift(float pitch)
328328
{
329-
return expf(pitch * (M_LN2 / 12.0f));
329+
return expf(pitch * (float(M_LN2) / 12.0f));
330330
}
331331

332332
/**
@@ -336,7 +336,7 @@ namespace lsp
336336
*/
337337
inline float frequency_shift_to_semitones(float pitch)
338338
{
339-
return (12.0f / M_LN2) * logf(pitch);
339+
return (12.0f / float(M_LN2)) * logf(pitch);
340340
}
341341

342342
/**

include/lsp-plug.in/dsp-units/util/Crossover.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ namespace lsp
8888
enum crossover_slope_t
8989
{
9090
CROSS_SLOPE_OFF = 0,
91-
CROSS_SLOPE_LR2 = 1,
92-
CROSS_SLOPE_LR4 = 2,
93-
CROSS_SLOPE_LR8 = 3,
94-
CROSS_SLOPE_LR12 = 4,
95-
CROSS_SLOPE_LR16 = 5,
96-
CROSS_SLOPE_LR20 = 6,
97-
CROSS_SLOPE_LR24 = 7,
98-
CROSS_SLOPE_LR28 = 8,
99-
CROSS_SLOPE_LR32 = 9,
91+
CROSS_SLOPE_LR2 = 1, //! 12 dB/ocave
92+
CROSS_SLOPE_LR4 = 2, //! 24 dB/ocave
93+
CROSS_SLOPE_LR8 = 3, //! 48 dB/ocave
94+
CROSS_SLOPE_LR12 = 4, //! 72 dB/ocave
95+
CROSS_SLOPE_LR16 = 5, //! 96 dB/ocave
96+
CROSS_SLOPE_LR20 = 6, //! 120 dB/ocave
97+
CROSS_SLOPE_LR24 = 7, //! 144 dB/ocave
98+
CROSS_SLOPE_LR28 = 8, //! 168 dB/ocave
99+
CROSS_SLOPE_LR32 = 9, //! 192 dB/ocave
100100
};
101101

102102
/** Crossover, splits signal into bands, calls processing handler (if present)

0 commit comments

Comments
 (0)