Old 09-18-2018, 08:25 PM   #1
Time Waster
Human being with feelings
 
Time Waster's Avatar
 
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
Default Another JS Trap for Young Players? (Solved)

I discovered today that if you add an integer to a sample value, thus: spl0+1 the result is the value of spl1, not the value of spl0 with 1 added to it!

To get the desired value, use (spl0)+1 or spl(0)+1. This is not documented and I mention it because I wasted a good half hour trying to track it down. I didn't experiment with subtraction or non integers, but I know that spl0*some_number works as expected. Go figure.
__________________
Mal, aka The Wasters of Time
Mal's JSFX: ReaRack2 Modular Synth

Last edited by Time Waster; 09-19-2018 at 06:10 PM.
Time Waster is offline   Reply With Quote
Old 09-18-2018, 09:31 PM   #2
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
Default

you mean doing
Code:
 a = spl0;
 a +=1; 
 b = spl0+1;
would result in a being different from b ?

This would be a nasty bug and hard to believe to happen.

-Michael
mschnell is offline   Reply With Quote
Old 09-18-2018, 10:32 PM   #3
Time Waster
Human being with feelings
 
Time Waster's Avatar
 
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
Default

Yes, that is what I mean. There is some strange logic to it, but It seems like a bug to me. spl0+1 gives the same result as spl(0+1).
__________________
Mal, aka The Wasters of Time
Mal's JSFX: ReaRack2 Modular Synth

Last edited by Time Waster; 09-18-2018 at 10:48 PM.
Time Waster is offline   Reply With Quote
Old 09-19-2018, 12:20 AM   #4
bezusheist
Human being with feelings
 
bezusheist's Avatar
 
Join Date: Nov 2010
Location: Mullet
Posts: 829
Default

i can't confirm this...
"spl0+1" works as expected.
__________________
I like turtles
bezusheist is offline   Reply With Quote
Old 09-19-2018, 01:22 AM   #5
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Me neither. Working correctly here.
IXix is offline   Reply With Quote
Old 09-19-2018, 03:17 AM   #6
Time Waster
Human being with feelings
 
Time Waster's Avatar
 
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
Default

Hmm, weird. I definitely fixed the problem by simply bracketing the I spl0. I'll have to investigate further.
__________________
Mal, aka The Wasters of Time
Mal's JSFX: ReaRack2 Modular Synth
Time Waster is offline   Reply With Quote
Old 09-19-2018, 08:31 AM   #7
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
Default

I can't confirm, either.

see this code:

Code:
desc:spl0test

@sample
  c += 1;
  c >= 100000 ? (  
    c = 0;
    x0  = spl0;
    x1  = spl0+1;
    x11 = x0+1;
    xd = x1 - x11;
  );
Placed after a noise generator and watching the debug window.

-Michael
mschnell is offline   Reply With Quote
Old 09-19-2018, 06:08 PM   #8
Time Waster
Human being with feelings
 
Time Waster's Avatar
 
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
Default

Today I removed the brackets that I put in yesterday and it all worked fine. I suspect the problem was that I had not done a full recompile/reset, so maybe that is the lesson to be learned, if things aren't working as expected, do a recompile/reset first.
__________________
Mal, aka The Wasters of Time
Mal's JSFX: ReaRack2 Modular Synth
Time Waster is offline   Reply With Quote
Old 09-19-2018, 09:30 PM   #9
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
Default

I'm not really sure what "recompile/reset" does besides loading the default values to the sliders.

It seems that simply storing recompiles and sets some variables to Zero, but seemingly not all. Maybe the @init section is executed.

Yet another weird kind of initialization is performed when Reaper looses and gets back the GUI focus (in Windows). (See the other thread I posted here.)

-Michael
mschnell 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 05:34 AM.


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