«Visual gain reduction meter» by jpdrecourt

on 15 Mar'20 13:21 in guicompressiongain reductionvisual osc

Simple visualisation of the gain reduction for effects like compression. It can be run in its own editor window and requires only minimal modification of the original code. Uses OSC messages like in the example of LevelIndicator.

There's an implementation exemple at the bottom of the code.

The main trick is that the meter actually shows (1 - gain_reduction) but the colours are switched between the background and the meter to give the illusion of an inverted meter.

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
({
	// Code to add in the synth to monitor
	/*
	var grBefore, grAfter;
	//// Some code
	grBefore = __signal_to_measure__; // Gain reduction measurement
	//// UGen to measure
	grAfter = __signal_to_measure__; // Gain reduction measurement
	SendReply.kr(Impulse.kr(10), '/level', [Amplitude.kr(grAfter - grBefore).lag(0, 1)]); // Gain Reduction measurement
	//// Some more code
	*/
	// Parameters
	var maxReduc = -6; // Maximum gain reduction indicated
	var nIntervals = 10; // Number of ticks (except the zero)
	var width = 40; // Width of the indicator in px
	var height = 300; // Height of the indicator in px
	var winName = "Gain Reduction"; // Name of the window
	var window, indicator, layout, oscFn;
	// Window creation
	window = Window("Gain reduction").front;
	window.setInnerExtent(width, height);
	// Level indicator setup
	indicator = LevelIndicator().fixedWidth_(width).fixedHeight_(height);
	indicator.numTicks = nIntervals + 1;
	indicator.numMajorTicks = 3;
	indicator.warning = 0.dbamp;
	indicator.critical = 0.dbamp;
	indicator.background = Color.new255(246, 184, 0);
	indicator.meterColor = Color.black;
	// Layout of the window
	layout = HLayout();
	layout.add(nil);
	layout.add(VLayout(indicator));
	layout.add(VLayout(StaticText().string_("0.0dB"), nil, StaticText().string_((maxReduc/2.0).asString ++ "dB"), nil, StaticText().string_((1.0*maxReduc).asString ++ "dB")
	));
	layout.add(nil);
	window.layout = layout;
	window.onClose_({oscFn.free;});
	// Level indicator update
	oscFn = OSCFunc({arg msg;
		{
			indicator.value = (1-msg[3]).ampdb.linlin(maxReduc, 0, 0, 1);

		}.defer;
	}, '/level', s.addr);
}.fork(AppClock);
) 

// Try it with this simple example
(

// something to meter
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");

x = {
	var colum, noise, imp, delimp, mul = 1, before, after;
	delimp = Delay1.kr(imp);
	colum = PlayBuf.ar(1, b, BufRateScale.kr(b), loop: 1)!2 * mul;

	before = colum; // Gain reduction measurement
	colum = Compander.ar(colum, colum,
		thresh: MouseX.kr(0.01, 1),
		slopeBelow: 1,
		slopeAbove: 0.5,
		clampTime:  0.01,
		relaxTime:  0.01
	);
	after = colum; // Gain reduction measurement
	SendReply.kr(Impulse.kr(10), '/level', [Amplitude.kr(after - before).lag(0, 1)]); // Gain Reduction measurement
	colum
}.play;

CmdPeriod.doOnce({x.free; b.free});
)
descendants
«Re: Visual gain reduction meter» by kergener (private)
«Re: Visual gain reduction meter» by kergener (private)
full graph
raw 2407 chars (focus & ctrl+a+c to copy)
reception
comments