Faust Compressors
-
OK so I thought I'd like to try out the Faust compressor code, so I created my scriptnode, with a code.faust node and added a file like this:
// Faust Source File: faustCompFile // Created with HISE on 2023-02-15 import("stdfaust.lib"); //strength: strength of the compression (0 = no compression, 1 means hard limiting, >1 means over-compression) strength = hslider("Strength", 0, 0, 1, 0.01); //thresh: dB level threshold above which compression kicks in thresh = hslider("Thresh", 0, -60, 0, 0.1); //att: attack time = time constant (sec) when level & compression going up att = hslider("Attack", 0, 0, 2, 0.01); //rel: release time = time constant (sec) coming out of compression rel = hslider("Release", 0, 0, 3, 0.01); //knee: a gradual increase in gain reduction around the threshold: below thresh-(knee/2) there is no gain reduction, above thresh+(knee/2) there is the same gain reduction as without a knee, and in between there is a gradual increase in gain reduction. knee = hslider("knee", 0, 0, 8, 0.1); //prePost: places the level detector either at the input or after the gain computer; this turns it from a linear return-to-zero detector into a log domain return-to-threshold detector //prePost = hslider("Mode", 0, 0, 1, 1); //link: the amount of linkage between the channels. 0 = each channel is independent, 1 = all channels have the same amount of gain reduction //link = hslider("Link", 0, 0, 1, 0.01); process = co.RMS_compression_gain_N_chan(strength,thresh,att,rel,knee,1,0,2);
This compiles fine --- but it massively reduces the output to nearly zero, so I think I'm doing something wrong. I checked the faust library documentation but its a little scant for the compressor values - so its not much help - anyone have any ideas?
-
@Lindon I think you're missing the channel I/O blocks in process.
si.bus(N) : RMS_compression_gain_N_chan_db(strength,thresh,att,rel,knee,prePost,link,N) : si.bus(N)
I think this would work:
process = _,_: co.RMS_compression_gain_N_chan(strength,thresh,att,rel,knee,1,0,2) :_,_;
-
@Dan-Korneff Thanks Dan, but sadly no - still cutting the volume to zero - it seems to be adding in some inaudible frequencies as when I turn on the scriptnode fx the meters got all he way up....
-
@Lindon This example doesn't work in the online Faust IDE either
https://faustide.grame.fr/ -
@Dan-Korneff said in Faust Compressors:
@Lindon This example doesn't work in the online Faust IDE either
https://faustide.grame.fr/yeah so I just found myself...
-
@Lindon ..and I cant find the source of the faust provided working demo either...
-
Okay for everyone who ends up here asking why the Faust compressors dont work.....
The compressors (both linear and dB) do NOT output an attenuated signal....they output the attenuation value. So you will need to take your input signal and multiply it with the results of these "compressors", for example:
// Faust Source File: compTest // Created with HISE on 2023-02-15 import("stdfaust.lib"); //strength: strength of the compression (0 = no compression, 1 means hard limiting, >1 means over-compression) strength = hslider("Strength", 0, 0, 1, 0.01); //thresh: dB level threshold above which compression kicks in thresh = hslider("Thresh", 0, -60, 0, 0.1); //att: attack time = time constant (sec) when level & compression going up att = hslider("Attack", 0, 0, 2, 0.01); //rel: release time = time constant (sec) coming out of compression rel = hslider("Release", 0, 0, 3, 0.01); //knee: a gradual increase in gain reduction around the threshold: below thresh-(knee/2) there is no gain reduction, above thresh+(knee/2) there is the same gain reduction as without a knee, and in between there is a gradual increase in gain reduction. knee = hslider("knee", 0, 0, 8, 0.1); //prePost: places the level detector either at the input or after the gain computer; this turns it from a linear return-to-zero detector into a log domain return-to-threshold detector //prePost = hslider("Mode", 0, 0, 1, 1); //link: the amount of linkage between the channels. 0 = each channel is independent, 1 = all channels have the same amount of gain reduction //link = hslider("Link", 0, 0, 1, 0.01); compress(left,right) = left,right : co.RMS_compression_gain_N_chan(strength,thresh,att,rel,knee,1,0,2) : *(left), *(right); process = compress;
My thanks to the Faust Slack members for this insight....
-
@Lindon However - right now this code seems to crash HISE or fail the DLL build process...