MasterFX a highly configurable chain of effects on the main outputs

see also: ProxyChain

(

s.boot;

// add a few global filter functions to use - these are then available by name.

ProxyChain.add(

\leakDC, \filter -> { |in, leak=0.99| LeakDC.ar(in, leak) },

\rollClip, \filter -> { |in, clip=0.99, pole=0.2|

OnePole.ar(in.clip2(clip), pole ** 0.7);

},

\krush, \filter -> { |in, bits=16, downsamp=2|

var down;

in = in.round(0.5 ** bits);

down = Latch.ar(in, Impulse.ar(SampleRate.ir / downsamp.max(2)));

// below 1/2 downsamp, do xfade:

blend(in, down, (downsamp - 1).clip(0, 1));

},

\ampFin, \filter -> { |in, limDrive=1, ampLimit=0.8, postAmp=1 |

Limiter.ar(in * limDrive, ampLimit) * postAmp;

}

);

// and specs for them fof gui control.

Spec.add(\leak, [0.5, 0.999, \exp]);

Spec.add(\clip, [0.0, 1, \amp]);

Spec.add(\pole, [0, 0.95, \lin]);

Spec.add(\bits, [16, 1]);

Spec.add(\downsamp, [1, 100, \exp]);

Spec.add(\limDrive, \amp4);

Spec.add(\ampLimit, \amp);

Spec.add(\postAmp, \amp4);

)

*new(server, numChannels, slotNames, busnum)

server: the server on which the MasterFX chain will run;

numChannels: the number of channels it will work on,

default is server.numOutputBusChannels

slotNames: the names of the filters/functions to be used, in order of execution;

busnum: the busnumber where it will process audio, default = 0.

(

m = MasterFX.new(server: s,

numChannels: 8,

slotNames: [\leakDC, \krush, \rollClip, \ampFin],

busIndex: 0);

m.gui(nSliders: 12);

)

{ PinkNoise.ar(0.5) * LFNoise2.kr([5, 8, 13, 21]).max(0); }.play;

s.scope(8);

// kick the effects in at full wet level

m.pxChain.add(\leakDC, 1);

m.pxChain.add(\rollClip, 1);

m.pxChain.add(\dualComp, 1);

m.pxChain.add(\ampFin, 1);

// make a more specific gui - see also ProxyChainGui

(

m.pxChain.gui(\Mestre, [

[\leakDC, \slotCtl, 1],

[\rollClip, \slotCtl, 1],

[\krush, \slotCtl, 1],

[\ampFin, \slotCtl, 1],

[\RESET, \extra, { m.pxChain.add(\leakDC, 1).add(\ampFin, 1) }],

])

)

m.pxChain.remove(\leakDC, 1);

m.pxChain.remove(\rollClip, 1);

m.pxChain.remove(\krush);

m.pxChain.remove(\ampFin, 1);

// removing a MasterFX

MasterFX.all; // all masterFX, one per server, live here.

MasterFX.clear(\localhost); // clear one specific masterfx

MasterFX.all; // gone now.

MasterFX(Server.internal, 8, [\leakDC, \rollClip, \dualComp, \ampFin]);

MasterFX.all;

MasterFX.clear; // clear all mfxes

MasterFX.all;

p = ProxySpace.push;

~pink = { PinkNoise.ar * SinOsc.ar };

~pink.play;

ProxyMixer(p);

z = MasterFX(s, 8, [\leakDC, \rollClip, \dualComp, \ampFin]);

z.gui;

ToDo:

maybe at some point one will want separate MasterFX for different output groups

on the same server. in that case, remove storage by server name, and use freely

given names.