Old 02-14-2020, 06:38 AM   #1
shades13
Human being with feelings
 
Join Date: Feb 2020
Posts: 3
Default Translating JSFX to C++

Hi,

So I’m somewhat of a hobby programmer but have been creating my own JSFX for quite a while now. Over the past few weeks, I’ve been starting to port some of my JSFX scripts into WDL-OL so that I can compile them on my Mac and use them in Logic, since there’s no Audio Unit version of ReaJS.

I’ve had great success with a few of them, but others don’t work anything like has intended and massively overload/clip/produce generally weird results. I think the core of the issue is I don’t understand how EEL translates over into the different math types available in C++.

In particular, I have one plugin, which is a heavily-modified version of the Liteon Deesser, which doesn’t work at all.

I understand that EEL uses doubles for all numbers, but how does this translate into C++?
With C++ doubles, do I need to put decimal points after every number, so e.g. 1 become 1.0 to make sure it is calculated as a double, even when the variable type is specified as a double? And what other potential snags are there to get caught on that could be affecting my results?
shades13 is offline   Reply With Quote
Old 02-14-2020, 08:26 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by shades13 View Post
so e.g. 1 become 1.0 to make sure it is calculated as a double, even when the variable type is specified as a double?
Yes, this can be a potential issue.

For example :

Code:
int x = 10;
int y = 11;
double z = x/y; // this is *not* going be 0.909090 or so, it will be 0
C++ calculates the expressions on the right of the = first, using the types those variables have. It doesn't first look what is the type of the variable you are assigning the result to. In the above example, the division is done as integers, resulting in 0 and then that is assigned to the double.

You can use a cast like this to force the calculation to happen as floating point :

Code:
int x = 10;
int y = 11;
double z = (double)x/y;
Or of course, by just using floating point variables to begin with. (If you are using numeric literals, then yes, you should use 1.0 instead of 1 and so on.)

Other possible issue when converting EEl/JesuSonic code to C++ could be that errors might be handled differently when calling the numerical functions or doing arithmetic. Eel might for example return 0.0 for calculations that in C++ will cause the result to be inf(inity) or nan (not-a-number). Justin could probably explain if there are any possible issues like that. (But if such cases exist, then the original JesuSonic plugin code was kind of wrong to begin with...)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 02-14-2020 at 10:33 AM.
Xenakios 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 08:35 PM.


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