Old 01-05-2020, 11:00 AM   #1
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 65
Default Anyone who has PluginDoctor?

Hi

If anyone here has Plugin Doctor and would like to help out?

This JS-limiter/fatterner distorts a bit. However Id like to know how much of that is digital distortion versus harmonic distortion?

Theres two versions below. One original + one where Ive tried a way to "fix" aliasing. It seems to work a bit but Ive only checked with a regular spectogram. So a check of that would be awesome.

Many thanks /danerius

=====================================

desc:Loud Sinner Danerius

slider1:2.2<1.5,3,0.01>Keep between 1.8 <-> 2.2
slider2:1<0.5,1.5,0.01> Gain Staging
slider3:1<0,2,0.01>Master Volume

@init
bpos=0;

@slider
//factor = slider1;

@sample

tempL = spl0 * slider2;
tempR = spl1 * slider2;

tempL = sin ($pi * tempL / slider1);
tempR = sin ($pi * tempR / slider1);

spl0 = tempL * slider3;
spl1 = tempR * slider3;

===================================

desc:Anti-Alias Sinner Danerius

//slider1:0<0,100,1>Analog (%)
//slider2:0<0,100,1>Glue (%)
slider3:2.6<1.5,3,0.01>Character (%)
slider4:1<0.5,1.5,0.01>Drive (%)
slider5:-0.3<-120,0,0.1>Max Vol (dB)

@init
bpos=0;

@slider
threshold = 2 ^ (slider5/6);

@sample

//Limiter
//Straight processing
tempL1 = (spl0 * slider4);
tempR1 = (spl1 * slider4);

tempL1 = sin ($pi * tempL1 / slider3);
tempR1 = sin ($pi * tempR1 / slider3);

//Mirror processing
tempL2 = (spl0 * slider4) * -1;
tempR2 = (spl1 * slider4) * -1;

tempL2 = sin ($pi * tempL2 / slider3);
tempR2 = sin ($pi * tempR2 / slider3);

//Summing of Straight + Mirror
spl0 = (tempL + (tempL2 * -1)) * threshold;
spl1 = (tempR + (tempR2 * -1)) * threshold;
//
danerius is offline   Reply With Quote
Old 01-05-2020, 05:50 PM   #2
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 774
Default

TempL and TempR aren’t defined in the second script, so it’s basically just creating an inverted version of the first script, no harmonic difference. There is nothing in the second script that would reduce aliasing. If you look at Loser/saturation you’ll see a method of implementing sin() distortion that adjusts the amount of curvature, use that as a reference.

Note that once x hits +/- slider4/(2*slider3) it will cause foldover distortion, probably what you mean by “digital”. Loser/saturation prevents this by limiting the input with min/max.

Probably the simplest method to antialias would be oversampling, you should be able to find code examples in my post history, there are a few jsfx oversampling libraries and methods that have been posted here.

Desmos Calculator is a good online calculator, I strongly suggest graphing your functions out to help see what the functions are doing, eg in Loser/saturation.
SaulT is offline   Reply With Quote
Old 01-06-2020, 12:18 PM   #3
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 65
Default

Quote:
Originally Posted by SaulT View Post
TempL and TempR aren’t defined in the second script, so it’s basically just creating an inverted version of the first script, no harmonic difference. There is nothing in the second script that would reduce aliasing. If you look at Loser/saturation you’ll see a method of implementing sin() distortion that adjusts the amount of curvature, use that as a reference.

Note that once x hits +/- slider4/(2*slider3) it will cause foldover distortion, probably what you mean by “digital”. Loser/saturation prevents this by limiting the input with min/max.

Probably the simplest method to antialias would be oversampling, you should be able to find code examples in my post history, there are a few jsfx oversampling libraries and methods that have been posted here.

Desmos Calculator is a good online calculator, I strongly suggest graphing your functions out to help see what the functions are doing, eg in Loser/saturation.
Hi Saul

Its supposed to foldover, thats the point of the math formula But its supposed to produce harmonic distortion. Thats what I wanted to check with Plugin Doctor.
https://www.desmos.com/calculator/p9vhmx065j

The idea with doing a regular plus a mirror image math operation is the same as with XLR-Cables and humbuckers. Two things out of phase gets the same distortion added and then cancelled out with a 180 phase reversal. Wether that works in this domain or not Ive yet to find out. The idea is super simple... Someone must have tried it before me...

Ive made one simple distortion with Tales oversample.jsfx. I'll have a go with this one as well

Many thanks /danerius
danerius is offline   Reply With Quote
Old 01-06-2020, 04:16 PM   #4
ErBird
Human being with feelings
 
Join Date: Jan 2017
Posts: 166
Default

Quote:
Originally Posted by danerius View Post
The idea with doing a regular plus a mirror image math operation is the same as with XLR-Cables and humbuckers. Two things out of phase gets the same distortion added and then cancelled out with a 180 phase reversal.
I understand the logic, but this won't work. XLR cables and humbuckers work because noise is being added to the signal. Aliasing is a entirely different from noise. Plus sin(x) is an odd function, so sin(x) = -sin(-x). The "mirroring" code accomplishes nothing but doubling the signal level.

Quote:
Originally Posted by danerius View Post
This JS-limiter/fatterner distorts a bit.
It distorts much more than a bit. I would hardly refer to this as a limiter/fattener. It's a sine distortion, about as nasty as distortions come.

Sine Distortion Foldover:
https://www.desmos.com/calculator/mvzdurbnoy

Quote:
Originally Posted by danerius View Post
However Id like to know how much of that is digital distortion versus harmonic distortion?
You're trying to discern how much of the distortion is harmonic vs. aliasing? I don't think PluginDoctor is going to do anything for you that a sine generator and Voxengo Span cannot. Reaper comes with "tone generator" and Span is free. MOscilloscope is also useful, but none of these are going to help you pick the aliasing out of the signal.

Quote:
Originally Posted by danerius View Post
slider3:2.6<1.5,3,0.01>Character (%)
slider4:1<0.5,1.5,0.01>Drive (%)
...
tempL1 = (spl0 * slider4);
tempR1 = (spl1 * slider4);
...
tempL1 = sin ($pi * tempL1 / slider3);
tempR1 = sin ($pi * tempR1 / slider3);
Why do you have two parameters that affect input gain? Turning up "character" lowers input gain, this seems counter-intuitive and not good.
ErBird is offline   Reply With Quote
Old 01-07-2020, 09:28 AM   #5
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 65
Default

Quote:
Originally Posted by ErBird View Post
I understand the logic, but this won't work. XLR cables and humbuckers work because noise is being added to the signal. Aliasing is a entirely different from noise. Plus sin(x) is an odd function, so sin(x) = -sin(-x). The "mirroring" code accomplishes nothing but doubling the signal level.

You're trying to discern how much of the distortion is harmonic vs. aliasing? I don't think PluginDoctor is going to do anything for you that a sine generator and Voxengo Span cannot. Reaper comes with "tone generator" and Span is free. MOscilloscope is also useful, but none of these are going to help you pick the aliasing out of the signal.

Why do you have two parameters that affect input gain? Turning up "character" lowers input gain, this seems counter-intuitive and not good.
Hi

Seems the humbucker-idea was too good to be true. No worries. Ideas are cheap

Ive done the tone generator + spectogram bit. It was inconclusive. Hence me asking about Plugin Doctor.

The "character" changes the slope of the waveshaper. Turning it up reduces the overall loudness but its not really a gain slider as such. Yes its counter intuitive. And yes its a prototype.

Best regards /danerius

PS. The waveshaper in Desmos. "b" changes the shape ie. the "character" slider. DS
https://www.desmos.com/calculator/8xixpgfklc
danerius is offline   Reply With Quote
Old 01-07-2020, 12:31 PM   #6
ErBird
Human being with feelings
 
Join Date: Jan 2017
Posts: 166
Default

Quote:
Originally Posted by danerius View Post
The "character" changes the slope of the waveshaper. Turning it up reduces the overall loudness but its not really a gain slider as such.
...
PS. The waveshaper in Desmos. "b" changes the shape ie. the "character" slider.
https://www.desmos.com/calculator/8xixpgfklc
It may appear that way, but it's misleading. The reality is multiplying the argument of sin(x) by a constant is equivalent to changing the input gain, it's not really changing the waveshaper shape or the overall loudness. If you split the equation into parts this becomes apparent.

Input x
https://www.desmos.com/calculator/ymfxlpr83o

Input sin(x)
https://www.desmos.com/calculator/fzpmwdcnrw

ErBird is offline   Reply With Quote
Old 01-07-2020, 06:12 PM   #7
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 774
Default

I really recommend the way Loser/Saturation does it. Mathematically it looks like this (albeit I’m using a cubic polynomial instead of the sin function)...

M(x) = a*x - a*a*a*x*x*x/b
N(x) = a - a*a*a/b

Out = m(x)/n(x)

Where a is 0.01 to 1, amount of saturation
And b is 3 to perhaps 6, lower numbers mean more max nonlinearity (this is “character”)

Note that n(x) can be precomputed. Loser/saturation does this (I think it is “bar” in that code).

Check my post history for stuff about cubic polynomials like this, you can think of it as a truncated Taylor polynomial, with a adjusting between the approximation for sine and the approximation for hyperbolic tangent.
SaulT is offline   Reply With Quote
Old 01-09-2020, 07:13 AM   #8
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 65
Default

Thanks ErBird and SaulT

I understand what youre saying but not the point of it. What am I missing? Does it make for better code to use polynomials? Is the math more accurate? Please elaborate... Im here to learn

The formula is doing what I am expecting it to do. Its a waveshaper that fold over on itself. Its meant to do that. Its meant to be producing harmonic distortion. Im looking to minimize the aliasing.

Heres three screen shots of an oscilloscope. One with overshooting. One thats squaring the sine. And one thats lowering the peak. Just as expected

Much appreciated /danerius
Attached Images
File Type: png FoldOver.png (43.2 KB, 10 views)
File Type: png Square.png (40.8 KB, 8 views)
File Type: png Sine.png (40.9 KB, 8 views)
danerius is offline   Reply With Quote
Old 01-11-2020, 10:04 PM   #9
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 774
Default

Okay, so I'll phrase this a different way.

Code:
slider3:2.6<1.5,3,0.01>Character (%)
slider4:1<0.5,1.5,0.01>Drive (%)
...
tempL1 = (spl0 * slider4);
...
tempL1 = sin ($pi * tempL1 / slider3);
is the same as

Code:
tempL1 = sin($pi * tempL1 * spl0 * slider4 / slider3 );
That means that all you're doing is multiplying your input by a constant. Look at ErBird's first Desmos link, this is the equivalent to what you are doing, except using a single number instead of a ratio between two numbers. You could replace slider3 and slider4 with one variable, as below, and it would be precisely equivalent...

Code:
slider5:1<0.17,6,0.01>Scaling constant
...
tempL1 = sin ($pi * spl0 * slider5);
This is what ErBird's first Desmos graph shows. You need to graph this out for yourself and understand it. Slider3 and slider4 don't represent anything meaningful on their own, their ratio forms a constant. Not useful at best and misleading and confusing at worst.

I thought it would be helpful if I shared a useful variation of the Loser/Saturation algorithm instead of repeating it almost verbatim. I'm very fond of my variation, because it is more adaptable than sin()... it also doesn't do multiple levels of foldover distortion the way sin() does, but to me that's a feature and not a bug...

...Okay, this is a graph of the Loser/Saturation function. The reason it is a good algorithm is that the slider does something meaningful - it doesn't just multiply the input of sin() by a constant, it changes how the function operates, making it more nonlinear as you push the slider along. Slider3/slider4 simply do not do this. You cannot get a linear response out of slider3/slider4, you can only get a sine curve.

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

...

I guess I'm assuming that you want a function that can go from "clean" to "dirty" in some way, I'm trying to show you that this is accomplished by using a waveshaping function that goes from linear (y=x) to very curved (y=sin(x)).

I don't know if I have any clever techniques for antialiasing deliberate foldover distortion beyond just oversampling... I have never liked the sound of it so never saw the point.
SaulT is offline   Reply With Quote
Old 01-14-2020, 09:30 AM   #10
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 65
Default

Hi SaulT and ErBird

First of all. Big thanks for taking the time and explaining all this. Im not a coder and my math skills are limited. Im gonna sink my teeth into all your suggestions and see if I can make it work in jsfx.

I didnt intend for it go from smooth to distorted. This was going to be one-trick clipper/limiter with an edgy sharp character. But your suggestions opens up a much broader use. Thanks

Ive talked to Chris from AirWindows regarding aliasing. He recommends raising the internal bit rate for distortion plugs. Oversampling doesnt help that much in his opinion. Havent tried it so cant confirm.

Thanks + best regards /danerius
danerius is offline   Reply With Quote
Old 01-16-2020, 04:47 PM   #11
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 774
Default

Ok, so I’ve got a crazy idea for you. Try this...

h(x)=x + x^3/6
f(x)=sin(h(a*x)/a)

When a is low then the output is pretty linear, although it will still fold over eventually. As a goes up it becomes more nonlinear and folds over more quickly. Might work for you.

Also, Reaper has internal 64 bit depth, so that part is fine.
SaulT is offline   Reply With Quote
Old 01-16-2020, 07:39 PM   #12
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 4,524
Default

The way that the sin function folds over is not particularly harmonic in nature. It can sort of look like octave doubling with certain pure waveforms which “overshoot” by a specific amount, but the period of the resulting wave is more dependent on the amplitude of the input signal than on the frequency. I’ve messed with it quite a bit and any time it’s allowed to fold over it really just gets ugly and unmusical really fast.

If you want to change the character of the distortion, you could try changing the symmetry of the clipping function either by applying a DC offset going in (and stripping it back out on the other side) or by processing both sides differently.

One of the things that I noticed with Loser saturation et al is that it tends to inflate the average/overall level. When it’s actually all the way to the sin function, for signals near zero, there is gain of about half pi. If you wanted “unity” in the more or less linear range, you’d have to divide the output by half of pi, and then your maximum peaks end up around 2/pi. I suppose that makes some sense if you’re using it as a maximizing final output kind of thing, but I’m not sure it’s always understood or expected with sin implementations.
ashcat_lt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:01 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.