Hello Fellow Faustians,
First of all many thanks to the developers and documentation writers:
due to their efforts, I was able to quickly write a plugin I had been
dreaming about for years, while getting my first taste of functional
programming.
Here is a simplified version, to explain what I did:
http://magnetophon.nl/sounds/magnetophon/Faust/MultiBusComp/MultiBusComp.four_mono_compressors-svg/process.svg
The feedback loop goes into the side-chain of the compressor.
This can be used in mixing and stem-mastering.
Normally, when you put a limiter on the master output, the signal with
the most energy (usually bass frequencies) will 'push away' all other
signals. With this plugin -YOU- decide who wins the fight for the master
bus.
For more explanation and a usage example, see the attached .dsp file.
Making a stereo version was a challenge and a version with an arbitrary
number of channels per compressor even more so. Adding metering was near
impossible for me.
I probably went about the routing and metering functions the wrong way;
I was hoping that by avoiding variables, I would get a block diagrams as
easily readable as the mono version.
Here is the full version, same as the the attachment:
http://magnetophon.nl/sounds/magnetophon/Faust/MultiBusComp/MultiBusComp.eight-stereo-compressors-svg/process.svg
I have the following questions:
1) Is there a better way to create the routing from the first link, but
generalized to an arbitrary number of compressors and channels per
compressor, as in the second link? Preferably one that produces a
readable block diagram.
What I did is depicted here:
http://magnetophon.nl/sounds/magnetophon/Faust/MultiBusComp/MultiBusComp.eight-stereo-compressors-svg/MultiRouting-0xaadaae8.svg
(line 129-159 of the attachment)
2) Would it be possible to change Faust so that "par(i,0,something)"
works? If not, why, and is there a workaround?
3) Would it be possible to make a function similar to "attach" but with
one input and no output, so you could tell the compiler to not optimize
out something without having to make convoluted routings?
4) I can't figure out how to implement a meter for total gain reduction,
generalized for any number of compressors and channels per compressor.
In pseudo-code it is as simple as:
add all input-signals,
get that signals envelope,
subtract it from the output-envelope,
display value.
In faust it gets very difficult (for me at least), because of the need
for "attach" combined with the particular routing I need.
5) Are feedback loops always one sample, no matter how many calculations
are done within it? Obviously excluding explicit delays...
6) It's probably my ignorance, but the stereo compressor in effect.lib
seems oddly implemented to me:
compressor_stereo(ratio,thresh,att,rel,x,y) = cgm*x, cgm*y with {
cgm = compression_gain_mono(ratio,thresh,att,rel,abs(x)+abs(y));
};
I would expect:
cgm =
min(compression_gain_mono(ratio,thresh,att,rel,x),compression_gain_mono(ratio,thresh,att,rel,y));
Are these equivalent? Is it an optimization? Am I nitpicking?
7) Is there a better way to implement gaincomp_multi(Nr), line 92-112
8) Up to 85 stereo compressors works, but 86 gives "Invalid Faust Code".
Why is that? (line 49)
Thanks for your attention, and enjoy MultiBusComp.
Bart.
declare name "CompBus";
declare version "1.0";
declare author "www.magnetophon.nl";
declare license "GNU";
declare copyright "(c)www.magnetophon.nl 2014";
import("effect.lib");
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// What is this?
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
This is a group of sidechain-compressors all mixed together.
The sidechains are connected to the output.
see process=CompBusMono; for a visual explanation.
This processor is used in mixing and stem-mastering. It's function is somewhere
between a master-limiter and a bus-compressor.
Normally, when you put a limiter on the master output, the signal with the most
energy (usually bass frequencies) will 'push away' all other signals. With this
plugin -YOU- decide who wins the fight for the master bus.
A typical usage example would be a pop/rock band mixed into four stereo buses:
bus 1: kick-drum and bass-guitar.
bus 2: all other drums and percussion
bus 3: everything that doesn't go to bus 1,2 or 4.
bus 4: vocals and vocal effects
All signals already have their desired dynamic range.
The MultiBusCompressor is followed by an external end-limiter. All compressor
thresholds are set a little bit below that of the end-limiter.
The end effect is that each input-bus retains it's full dynamic range, and only
starts compressing when all signals combined would otherwise trigger the
end-limiter.
Some useful tricks can be done:
The vocals get a compression ratio of 1:1, so they will not be compressed. They
do contribute to the side-chain signal, so if needed, they will push other
signals aside.
The kick and bass get the lowest threshold, infinite:1 ratio, a short attack,
longish release. This means they can have full power,but go out of the way when
they would have otherwise pumped the end limiter.
The other drums and percussion have the same threshold and ratio, with a
longish attack and a short release; they will punch into the end limiter and
then quickly go out of the way.
The bus with all other input signals has a threshold between that of the first
2 buses and that of the end limiter, with an infinite ratio, zero attack and
short release; It will retain it's full dynamic range, and go out of the way
only when the vocal needs headroom. Due to the zero attack it will also make
room for the transients of the drum and bass.
The end limiter now only has the short transients from bus 1 and the slightly
longer 'punches' from bus 2 to deal with, so it can have a short release
without causing distortion.
This is just one use case, I'm sure you can think of many more.
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// User prefferences
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// up to 85 stereo compressors works, but 86 gives "Invalid Faust Code"
NrCompressors = 8; //1 for a single compressor doesn't work, use
//process=FBcomp; instead. doesn't have in and out metering though...
//2 to 16, can be extended by writing more f(n) functions in SCcomp
ChanPerComp= 2; //1 for mono doesn't work, use
// process=CompBusMono;
// instead, doesn't have in and out metering though...
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user interface
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
meter_group(x) = (vgroup("[0]", x));
knob_group(x) = (vgroup("[1]", x));
ratio = knob_group(vslider("[1]ratio[unit::1]", 20, 1, 20 , 0.1));
thresh = knob_group(vslider("[2]thres[unit: dB]", 0, -70, 0 , 0.1));
att = knob_group(vslider("[3]att[unit: s]", 0, 0, 0.1 , 0.001));
rel = knob_group(vslider("[4]rel[unit: s]", 0.1, 0.01, 1 , 0.001));
envelop = abs : max ~ -(1.0/SR) : max(db2linear(-70)) : linear2db;
meter = _<:(_, (envelop :(vbargraph("[unit:dB][tooltip: input level in dB]",
-70, +6)))):attach;
multimeter = meter_group(hgroup("[1]",par(i,ChanPerComp,meter)));
//InMeter =
bus(ChanPerComp*NrCompressors)<:bus(ChanPerComp*NrCompressors),(bus(ChanPerComp*NrCompressors)
:> meter_group(vgroup("[1]",par(i,ChanPerComp,_<:(_,(envelop
:(hbargraph("[unit:dB][tooltip: input level in dB]", -70, +6)))):attach))): !,!
);
InMet= bus(ChanPerComp*(NrCompressors)):>
meter_group(vgroup("In:",par(i,ChanPerComp,envelop
:(hbargraph("[unit:dB][tooltip: input level in dB]", -70, +6)))));
InMetRoutInput=bus(ChanPerComp),par(i,ChanPerComp*(NrCompressors-1),!) ;
met=(InMetRoutInput,InMet):interleave(ChanPerComp,2):par(i,ChanPerComp,attach);
InMetRoutOutput= par(i,ChanPerComp,!),bus(ChanPerComp*(NrCompressors-1)) ;
me= bus(ChanPerComp*NrCompressors)<:bus(ChanPerComp*NrCompressors*2):met;
InMeter=bus(ChanPerComp*NrCompressors)<:me,InMetRoutOutput:>bus(ChanPerComp*NrCompressors);
OutMeter = meter_group(vgroup("Out:",par(i,ChanPerComp,_<:(_,(envelop
:(hbargraph("[2][unit:dB][tooltip:output level in dB]", -70, +6)))):attach)));
GR = linear2db : meter_group(vbargraph("[2] GR [unit:dB] [tooltip:
Gain reduction in dB]", -30,0));
displayGR = _<:_,GR : attach;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// compute the gain
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
gaincomp(x) = compression_gain_mono(ratio,thresh,att,rel,x);
//gaincomp_stereo = min(gaincomp,gaincomp) ;
gaincomp_multi(Nr) = f(Nr) with {
f(1)=gaincomp(_);
f(2)=min( gaincomp(_),gaincomp(_));
f(3)=f(1),f(2):min;
//f(n)=f(n-2),f(n-1):min;
f(4) =par(i,(2),min( gaincomp(_),gaincomp(_))):min;
f(5) =f(1),f(4):min;
f(6) =f(2),f(4):min;
f(7) =f(3),f(4):min;
f(8) =par(i,4,min( gaincomp(_),gaincomp(_)) ):par(i,(2),min):min;
f(9) =f(1),f(8):min;
f(10) =f(2),f(8):min;
f(11) =f(3),f(8):min;
f(12) =f(4),f(8):min;
f(13) =f(5),f(8):min;
f(14) =f(6),f(8):min;
f(15) =f(7),f(8):min;
f(16) =par(i,8,min( gaincomp(_),gaincomp(_)) ):par(i,4,min):par(i,(2),min):min;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// compressor building blocks
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// a feedback compressor
//FBcomp =_*_~gaincomp(_);
//a mono sidechain compressor
SidechainCompressor(v) = vgroup("Ch %v", gaincomp*meter):displayGR;
// a multi-channel version
SC(Nr)=par(i,Nr*2,_): (gaincomp_multi(Nr):displayGR<:par(i,Nr,_)),multimeter :
interleave(Nr,2): par(i,Nr,*);
SCcomp(Nr) = hgroup("",SC(Nr));
MasterCS(Nr) = hgroup("[1]MasterFB",SC(Nr)); //identical to SCcomp except
for the caption
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Stereo and multi routing
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the number of in and outputs
inputNr= (NrCompressors*ChanPerComp); //
totalNr= (ChanPerComp+inputNr); // total nr of inputs, including the feedback
outputNr= inputNr*2; //nr of outputs of the router, including a SC for each
compressor
Zero(Nr)= par(i,Nr,0); //make (Nr) outputs that output nothing
//make it pair up the feedback input with the audio inputs of
// multirouting, mono version
routing= (bus(1+NrCompressors)) <:
par(j,NrCompressors,(_,selector(j,NrCompressors)));
// select first ChanPerComp inputs from
// ((NrCompressors*ChanPerComp)+ChanPerComp)
SideChain(ChNr)=bus(totalNr)<:Zero(ChNr*2*ChanPerComp),par(i,ChanPerComp,selector(i,totalNr)),Zero(outputNr-(ChNr*2*ChanPerComp)-ChanPerComp);
//exception, needed cause par(i,0,something) doesn't work
FirstSideChain=bus(totalNr)<:par(i,ChanPerComp,selector(i,totalNr)),Zero(outputNr-ChanPerComp);
//Connect all SideChains
AllSC =
bus(totalNr)<:FirstSideChain,par(i,NrCompressors-1,SideChain(i+1)):>bus(outputNr);
// select audio bus(totalNr):
audio(ChNr)= par(i,ChanPerComp,!)
,(bus(inputNr)<:par(i,ChanPerComp,selector(i+ChanPerComp*ChNr,inputNr)));
//connect all the audio
AllAudio =bus(totalNr)<:par(i,NrCompressors,Zero(ChanPerComp),audio(i));
//and the complete routing
MultiRouting= bus(totalNr)<: AllSC, AllAudio:>bus(outputNr);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the complete CompBus
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CompBusMono = ((routing:(hgroup("CompBus", par(i, NrCompressors,
SidechainCompressor(i+1)):>_ )))~_) ;
FBcomp= ( hgroup("[2]FBcomp",SCcomp(ChanPerComp)) ) ~bus(ChanPerComp) ;
FFcomp= hgroup("[2]FFcomp",bus(ChanPerComp)<:( SCcomp(ChanPerComp) ));
SCFB(Nr)=hgroup("[1]MasterSC",(((interleave(Nr,2):par(i,Nr,*):gaincomp_multi(Nr):displayGR<:par(i,Nr,_)),multimeter)~(bus(Nr)):interleave(Nr,2):par(i,Nr,*)));
SCFBplusFF(Ch)= hgroup("Ch %Ch[Ch]",hgroup("",SCFB(ChanPerComp):FFcomp));
SCplusFF(Ch)= hgroup("Ch %Ch[Ch]",hgroup("",MasterCS(ChanPerComp):FFcomp));
CompBus=InMeter: ( hgroup("", MultiRouting:(par(i,NrCompressors,
SCplusFF(i+1)):>bus(ChanPerComp) )) ) ~ OutMeter ;
process = CompBus;------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries. Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users