@DanH Lets take a look at soft sat for example, the musicdsp dsp was this:
x < a:
f(x) = x
x > a:
f(x) = a + (x-a)/(1+((x-a)/(1-a))^2)
x > 1:
f(x) = (a+1)/2
There is also a note that is important to consider that is also posted by the author of the dsp above:
This only works for positive values of x. a should be in the range 0..1
We'll use that later
Now after creating a snexshaper file and creating the amount parameter (with range 0-1 as said in note) and in the snex code editor of the shaper, you'll see that there's already a base template that is provided. This template basically takes care of most of the stuff you'd need.
In the dsp, there's three values x, a, and f(x). Now a is commonly used as a variable for gain, and x is input while f(x) or y is the output. Next I initialized two variables gain for a and out for f(x). We don't need an input variable since there's a input parameter in the template that we can use. I created a separate method saturate(input) to separate things out to fix the problem mentioned in the dsp note. From there, you can see the code in the saturate method is exactly the same as the dsp but the dsp variables swapped out plus the return statement at the end.
Next in the getSample(input) method that was provided in the template, I made an if statement to solve the problem in the dsp note where only a positive value worked for the input, which wouldn't result in complete waveshaping. If the input was greater than 0, then saturate using the input, otherwise make the input negative and run it through the saturate function and then reverse the output to affect negative values as well.
Everything is set except the parameter linking. To link the parameter, I looked up on the forum for some snex shaper problems and someone had a video and I used the code they used. I don't know why it's not included in template but its the same for everything, create an if statement and if P (parameter?) is equal to 0 (index position of parameter), then link it!
That's pretty much it, the hard sat is the same but without the needing to make sure negative values of input are factored in