// Music 256a / CS 476a | fall 2016 // CCRMA, Stanford University // // Author: Romain Michon (rmichonATccrmaDOTstanfordDOTedu) // Description: Mono distortion effect. import("stdfaust.lib"); d = hslider("drive",0,0,1,0.01) : si.smoo; o = hslider("offset",0,-1,1,0.01) : si.smoo; g = hslider("gain",1,0,1,0.01) : si.smoo; distortion(drive,offset) = +(offset) : *(pregain) : clip : cubic : fi.dcblocker with{ pregain = pow(10,2*drive); // pregain range is 0 - 100 clip = min(1) : max(-1); // clip the signal between 1 and -1 cubic(x) = x - pow(x,3)/3; }; process = vgroup("distortion",distortion(d,o)*g);