View Single Post
Old 07-05-2019, 12:46 AM   #7
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 876
Default

Also, instead of clamping to +/- 1 you could do something like....

Code:
desc:Danerius Waveshaper
slider1:0.1<-0.3,0.3,0.01>parameter 

@init

bpos=0;


@slider

sliderpi = (1 - slider1 * $pi);


@sample

s0 = abs(spl0);
s0 > 1 ? ( s0 = sliderpi*(s0 - 1) + 1 ) : s0 = slider1 * sin(s0*$pi)+s0;
spl0 = s0 * sign(spl0);

s1 = abs(spl1);
s1 > 1 ? ( s1 = sliderpi*(s1 - 1) + 1 ) : s1 = slider1 * sin(s1*$pi)+s1;
spl1 = s1 * sign(spl1);
...No hard clipping, large signal values are handled gracefully. Also, this isn't really asymmetric, it has rotational symmetry. This makes it an odd function and you can check on a spectrogram, it is only creating odd harmonics. I like SPAN, I use it all the time, but of course there is a very handy JSFX spectrogram as well, you can find it if you look for gfx_analyzer.

Like, seriously though, test this code against the original. See what happens when you push a signal through that is greater than 0 dB. Compare it to what happens with this version.

https://www.desmos.com/calculator/wcdhdiixvp


(note that cos(pi*1) is -1, the cos() is there to show that I was taking the derivative of sine where x = 1 etc)

Last edited by SaulT; 07-05-2019 at 01:40 AM.
SaulT is offline   Reply With Quote