It seems to work just fine. Because you set the time constants to 0 you effectively make a waveshaper and not a compressor. Also using a constant waveform doesn't let you see what a compressor does. A compressor is a time variant effect that changes volume over time depending on the volume in the sidechain detector, so if you feed it a constant volume waveform the compressor will never change state. Only at the very beginning.
Here's your code only slightly modified and as you can see in the scope (set to 48000 samples at 48000 SR) the compressor is working just fine. import("stdfaust.lib"); ifNc((c,r)) = c,r : ifNc(outputs(r)/2); ifNc(1) = ba.if; ifNc(n) = _,_,ifNc(n-1) : ifNc(1); comp_gain_computer(thres,ratio,knee,in) = ifNc(2, 2*(in-thres)<-knee,in, 2*(abs(in-thres))<=knee,in+(((1/(ratio-1))*((in-thres+(knee/2))^2))/(2*knee )), thres ); comp(thres,ratio,knee,attack,release) = _<:_,(ba.linear2db<:(_*-1, comp_gain_computer(thres,ratio,knee):>+):si.onePoleSwitching(release,attack) :ba.db2linear):>*; process = ((ba.pulsen(24000, 48000)*0.3 +0.5) *os.lf_sawpos(800)) : comp(-10 ,10,10,0.001,0.25); Thomas Hopman - TomaTek-Audio - SureShot Studio +31 (0)6 17115051 Op ma 1 jan 2024 om 08:20 schreef Autumn Cheney via Faudiostream-users < faudiostream-users@lists.sourceforge.net>: > hi, > > i need help with getting a program of mine to work. i'm trying to design a > compressor based on the implementation details given in this: > https://www.mathworks.com/help/audio/ref/compressor-system-object.html > but for some reason my implementation isn't working correctly > > here's my code, don't mind the redefiniton of ifNc (i'm working with an > older version of faust) > > import("stdfaust.lib"); > > ifNc((c,r)) = c,r : ifNc(outputs(r)/2); > ifNc(1) = ba.if; > ifNc(n) = _,_,ifNc(n-1) : ifNc(1); > > comp_gain_computer(thres,ratio,knee,in) = ifNc(2, > 2*(in-thres)<-knee,in, > 2*(abs(in-thres))<=knee,in+(((1/(ratio-1))*((in-thres+(knee/2))^2))/(2* > knee)), > thres > ); > > comp(thres,ratio,knee,attack,release) = _<:_,(ba.linear2db<:(_*-1, > comp_gain_computer(thres,ratio,knee):>+):si.onePoleSwitching(release, > attack):ba.db2linear):>*; > > > process = os.lf_sawpos(50) : comp(-10,20,10,0,0); > > i have the attack and release turned to zero for testing. if you look the > oscilloscope in the faust ide you'll see the saw wave isn't shaped > correctly, and i can't figure out why > > would someone take a look? thanks! > > _______________________________________________ > Faudiostream-users mailing list > Faudiostream-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/faudiostream-users >
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users