Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Visual gain reduction meter
name
code content
({ // 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}); )
code description
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.
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change