C++ conditional operator conversion help [GPL Code!]

Just starting out? Need help? Post your questions and find answers here.
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: C++ conditional operator conversion help

Post by mk-soft »

Boolean True

PB = 1
GCC = 1
VB6 = -1
VB.net = -1
Excel = 1
Automation variant = $FFFF

Code: Select all

Define a.i

!#include "stdbool.h";
!v_a = true;
Debug "GCC True = " + a
Not NULL is true
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: C++ conditional operator conversion help

Post by idle »

infratec wrote: Sat Sep 10, 2022 9:54 am Why ?

Code: Select all

env = rt * env + (1 - at) * ((fabs - env > 0) ? fbs - env : 0)
Has 2 posibilities:

Code: Select all

env = rt * env + (1 - at) * (fbs - env)
And

Code: Select all

env = rt * env + (1 - at) * (0)
The second case can be reduced to:

Code: Select all

env = rt * env
(In my opinion, I didn't checked it with a C compiler.
Yes your right. I Misread it, that's what (( :? )) are for clear any ambiguity in the statement at a glance

Code: Select all

Global.d env,at,fabs,rt 
	fabs = 0.997 
	at = 0.02
	rt = 0.01 
	
	env= 0.996 
	!v_env = v_rt * v_env + ((1 - v_at) * ((v_fabs - v_env > 0) ? v_fabs - v_env : 0));
	Debug env 
	
	env= 0.996 
	If fabs - env > 0 
	  env = rt * env + ((1 - at) * (fabs - env))
	Else 
	  env = rt * env  
	EndIf 
	
	Debug env 

AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: C++ conditional operator conversion help [GPL Code!]

Post by AndyMK »

It's nice to see everyone debating the correct way to translate the code but i just realized the source i posted is GPL. A shame i can't use it as the rest of my code is not compatible with GPL.
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: C++ conditional operator conversion help [GPL Code!]

Post by BarryG »

To get around the GPL restriction, you'd need to re-write it without using the original code, like the devs of ReactOS do. That is, perform a clean-room implementation of it. Specifically: get someone to describe to you how the algo works (without using any code), and you then write the algo code yourself based on the description.
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: C++ conditional operator conversion help [GPL Code!]

Post by AndyMK »

The Autor states his source of motivation.

Noise Gate:
https://www.dafx.de/paper-archive/2002/ ... miters.pdf

Compressor/Limiter:
http://eecs.qmul.ac.uk/~josh/documents/ ... ES2012.pdf
perform a clean-room implementation of it
Never heard this before.
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: C++ conditional operator conversion help [GPL Code!]

Post by BarryG »

Never heard this before.
It's like how I described. Or see here -> https://en.wikipedia.org/wiki/Clean_room_design
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: C++ conditional operator conversion help [GPL Code!]

Post by AndyMK »

Can someone describe how it works (I know)? And I'll re implement it. :shock:
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: C++ conditional operator conversion help [GPL Code!]

Post by idle »

If they wrote a paper about it it's not protected
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: C++ conditional operator conversion help [GPL Code!]

Post by AndyMK »

idle wrote: Sun Sep 11, 2022 10:42 am If they wrote a paper about it it's not protected
The author wrote the code based on a paper as far as I can tell. If what you say is the case, can I use my translation GPL free? I mean, what was the point of the source author making it GPL?

The source code comments use terminology directly lifted from the paper.
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: C++ conditional operator conversion help [GPL Code!]

Post by idle »

you're re implementing a published public domain algorithm. Are you linking to the authors code statically? No and if you're still worried turn it into a dll so you'll be able to use it without transfer of rights or claim.
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: C++ conditional operator conversion help [GPL Code!]

Post by AndyMK »

idle wrote: Sun Sep 11, 2022 11:16 am you're re implementing a published public domain algorithm. Are you linking to the authors code statically? No and if you're still worried turn it into a dll so you'll be able to use it without transfer of rights or claim.
Am I required to publish the PB DLL code?
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: C++ conditional operator conversion help [GPL Code!]

Post by Olli »

AndyMK wrote:Here is the original code and my conversion below it.

C++

Code: Select all

typedef struct  {
[etc...]
This day, you have added << [GPL code!] >> in the title of the subject.

Please read the licence of the real original code. Logically, it is described the several author(s) of the code, and several dates of creation and modifications.

I imagine this is not a sophisticated system, after having read this code extract. But the licence is ever important. So you have to insert in the head of the extract of the original code (the words you wrote), a minima, a hyperlink to a GNU GPL licence (a first text line) and the identity of the several authors (a second text line). It is so two text lines to be inserted in the original code (extract) you have published.

For the rest, if you keep the link with authors of the original code, there is no problem to modify it. But you have to keep the link with authors, as described in a GNU GPL licence.
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: C++ conditional operator conversion help [GPL Code!]

Post by AndyMK »

Olli wrote: Sun Sep 11, 2022 12:49 pm
AndyMK wrote:Here is the original code and my conversion below it.

C++

Code: Select all

typedef struct  {
[etc...]
This day, you have added << [GPL code!] >> in the title of the subject.

Please read the licence of the real original code. Logically, it is described the several author(s) of the code, and several dates of creation and modifications.

I imagine this is not a sophisticated system, after having read this code extract. But the licence is ever important. So you have to insert in the head of the extract of the original code (the words you wrote), a minima, a hyperlink to a GNU GPL licence (a first text line) and the identity of the several authors (a second text line). It is so two text lines to be inserted in the original code (extract) you have published.

For the rest, if you keep the link with authors of the original code, there is no problem to modify it. But you have to keep the link with authors, as described in a GNU GPL licence.
Yes I understand that but can I use it in my closed source code? At what point does modification become "different" ? The code functions as an audio limiter. There are many of them, most following the same coding pattern which is an emulation of a hardware equivalent.
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: C++ conditional operator conversion help [GPL Code!]

Post by idle »

If you use gpl code and make a dll with it, you're required to provide the source of the dll on request but you don't need to publish the source.
You can then use and link to that dll in your closed source project.
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: C++ conditional operator conversion help [GPL Code!]

Post by AndyMK »

idle wrote: Sun Sep 11, 2022 8:36 pm If you use gpl code and make a dll with it, you're required to provide the source of the dll on request but you don't need to publish the source.
You can then use and link to that dll in your closed source project.
I looked this up but couldn't find anything concrete. Can you link me to something that can confirm this?
Post Reply