-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathlufs_meter.dsp
50 lines (34 loc) · 1.14 KB
/
lufs_meter.dsp
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
// -*-Faust-*-
declare name "Soundsgood";
declare version "1.0";
declare author "Klaus Scheuermann";
declare license "GPLv3";
// double precision -double needed!
ebu = library("lib/ebur128.dsp");
import("stdfaust.lib");
// init values
Nch = 2; //number of channels
// main
process =
tone_generator :
si.bus(2)
: lufs_meter
: si.bus(2)
;
// tone_generator
tone_generator = os.osc(f) * g <: _,_ with{
g = vslider("tone_gen_gain",-50, -120,0,1):ba.db2linear;
f = vslider("tone_gen_freq[unit:Hz] [scale:log]",1000,20,20000,1);
};
// +++++++++++++++++++++++++ LUFS METER +++++++++++++++++++++++++
lk2 = par(i,2,kfilter : zi) :> 4.342944819 * log(max(1e-12)) : -(0.691) with {
// maximum assumed sample rate is 192k
maxSR = 192000;
sump(n) = ba.slidingSump(n, Tg*maxSR)/n;
envelope(period, x) = x * x : sump(rint(period * ma.SR));
//Tg = 0.4; // 3 second window for 'short-term' measurement
Tg = 3;
zi = envelope(Tg); // mean square: average power = energy/Tg = integral of squared signal / Tg
kfilter = ebu.prefilter;
};
lufs_meter(l,r) = l,r <: l, attach(r, (lk2 : vbargraph("[unit:dB]out-lufs-s",-120,0))) : _,_;