|
|
|
11-03-2019, 02:46 PM
|
#1
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
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
|
|
|
11-03-2019, 03:25 PM
|
#2
|
Human being with feelings
Join Date: Aug 2009
Location: NL
Posts: 1,453
|
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.
Last edited by sai'ke; 11-03-2019 at 03:36 PM.
|
|
|
11-03-2019, 04:16 PM
|
#3
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
Quote:
Originally Posted by sai'ke
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
|
|
|
11-03-2019, 07:08 PM
|
#4
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by sai'ke
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.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Last edited by Xenakios; 11-03-2019 at 07:22 PM.
|
|
|
11-04-2019, 12:12 AM
|
#5
|
Human being with feelings
Join Date: Aug 2009
Location: NL
Posts: 1,453
|
Haha, ah yes, ofc. I feel really silly now. I was only thinking of the integer case. Sorry, must've been sleeping. :P
|
|
|
11-04-2019, 08:33 AM
|
#6
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
Quote:
Originally Posted by Xenakios
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
|
|
|
11-04-2019, 09:19 AM
|
#7
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Quote:
Originally Posted by danerius
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);
|
|
|
11-05-2019, 11:38 PM
|
#8
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
Quote:
Originally Posted by Tale
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
|
|
|
11-06-2019, 12:45 AM
|
#9
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Quote:
Originally Posted by danerius
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.
|
|
|
11-06-2019, 04:17 AM
|
#10
|
Human being with feelings
Join Date: Oct 2018
Posts: 173
|
Quote:
Originally Posted by Tale
That line is just to show you (in the JSFX IDE) when the value is 0.999... not 1.
|
Ohh... Thanks
|
|
|
Thread Tools |
|
Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:45 AM.
|