Old 11-03-2019, 02:46 PM   #1
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 48
Default Why does this distort so much

H guys. If anyone knows why this distorts as much as it does? Id love know why? It even distorts at a slider value of "1" wich according to my thinking shouldnt do anything to the incoming signal? What am I missing?

Heres the Desmos curve that behaves nicely throughout the slider range.
https://www.desmos.com/calculator/ivpddpaqje
--------------------------------------------------------------------------
desc:Loctite

slider1:1<0.12,1.96,0.08>Glue

@init

@slider

@block

@sample
spl0= pow(spl0,slider1);
spl1= pow(spl1,slider1);
--------------------------------------------------------------------------

Thanks + best regards /Bo
danerius is offline   Reply With Quote
Old 11-03-2019, 03:25 PM   #2
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: NL
Posts: 665
Default

Can confirm some distortion for parameter value = 1 here too. If I hardcode the value of 1 in the pow it doesn't do that anymore though.

Looks like it's only returning positive values.

Weird.

As a temporary workaround you could use (I checked, it nulls perfectly):
spl0 = sign(spl0)*pow(abs(spl0),slider1);
spl1 = sign(spl1)*pow(abs(spl1),slider1);

But it seems like a bug.
__________________
[Tracker Plugin: Thread|Github|Reapack] | [Routing Plugin: Thread|Reapack] | [Filther: Thread|Github|Reapack] | [More JSFX: Thread|Reapack]

Last edited by sai'ke; 11-03-2019 at 03:36 PM.
sai'ke is offline   Reply With Quote
Old 11-03-2019, 04:16 PM   #3
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 48
Default

Quote:
Originally Posted by sai'ke View Post
Can confirm some distortion for parameter value = 1 here too. If I hardcode the value of 1 in the pow it doesn't do that anymore though.

Looks like it's only returning positive values.

Weird.

As a temporary workaround you could use (I checked, it nulls perfectly):
spl0 = sign(spl0)*pow(abs(spl0),slider1);
spl1 = sign(spl1)*pow(abs(spl1),slider1);

But it seems like a bug.
Hi Saike

I was trying to avoid coding with absolute values. Thats how I stumbled across this. Big thanks for the code. I'll just use that instead

Thanks + best regards /Bo
danerius is offline   Reply With Quote
Old 11-03-2019, 07:08 PM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,954
Default

Quote:
Originally Posted by sai'ke View Post

But it seems like a bug.
A bug in mathematics?

It's just how raising numbers to powers works, things get wonky when the base is a negative number and no proper result may be produced with computer floating point implementations.

The Desmos code is doing some non-standard trick to make the calculation/graphing work. The JesuSonic behavior is the standard way things work in the C math library. If one wants the symmetric function that works for negative inputs, the sign() and abs() method is required.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 11-03-2019 at 07:22 PM.
Xenakios is offline   Reply With Quote
Old 11-04-2019, 12:12 AM   #5
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: NL
Posts: 665
Default

Haha, ah yes, ofc. I feel really silly now. I was only thinking of the integer case. Sorry, must've been sleeping. :P
__________________
[Tracker Plugin: Thread|Github|Reapack] | [Routing Plugin: Thread|Reapack] | [Filther: Thread|Github|Reapack] | [More JSFX: Thread|Reapack]
sai'ke is offline   Reply With Quote
Old 11-04-2019, 08:33 AM   #6
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 48
Default

Quote:
Originally Posted by Xenakios View Post
A bug in mathematics?

It's just how raising numbers to powers works, things get wonky when the base is a negative number and no proper result may be produced with computer floating point implementations.

The Desmos code is doing some non-standard trick to make the calculation/graphing work. The JesuSonic behavior is the standard way things work in the C math library. If one wants the symmetric function that works for negative inputs, the sign() and abs() method is required.
Hi. I see. The Desmos curve only works with certain input numbers ie. he ones I put in the formula. And like I said. I thought I had found a workaround

Id better learn actual programming instead

Best regards /Bo
danerius is offline   Reply With Quote
Old 11-04-2019, 09:19 AM   #7
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 2,981
Default

Quote:
Originally Posted by danerius View Post
It even distorts at a slider value of "1" wich according to my thinking shouldnt do anything
Actually it works fine here initially, or when you type "1", because then the slider really is 1. However, if you double-click on it, then it gets reset to 0.99999999999999989 (I guess a rounding error because of the slider min/max values and/or step size), hence the dirstortion.

Code:
@slider
sprintf(#slider1, "%.17g", slider1);
__________________
Martinic Kee Bass - Scanner Vibrato - Elka Panther - Tale's JSFX Pack
Tale is offline   Reply With Quote
Old 11-05-2019, 11:38 PM   #8
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 48
Default

Quote:
Originally Posted by Tale View Post
Actually it works fine here initially, or when you type "1", because then the slider really is 1. However, if you double-click on it, then it gets reset to 0.99999999999999989 (I guess a rounding error because of the slider min/max values and/or step size), hence the dirstortion.

Code:
@slider
sprintf(#slider1, "%.17g", slider1);
Hi Tale

Sorry but I dont get it. I put the line of code in the @slider section. But theres no difference?

Best regards /Bo
danerius is offline   Reply With Quote
Old 11-06-2019, 12:45 AM   #9
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 2,981
Default

Quote:
Originally Posted by danerius View Post
I put the line of code in the @slider section. But theres no difference?
That line is just to show you (in the JSFX IDE) when the value is 0.999... not 1.
__________________
Martinic Kee Bass - Scanner Vibrato - Elka Panther - Tale's JSFX Pack
Tale is offline   Reply With Quote
Old 11-06-2019, 04:17 AM   #10
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 48
Default

Quote:
Originally Posted by Tale View Post
That line is just to show you (in the JSFX IDE) when the value is 0.999... not 1.
Ohh... Thanks
danerius 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 09:32 PM.


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