
Automated AVSTrans APE (beta)
By TomyLobo
7 Favourites43 Comments6K Views
wee! i finally made it!
With some help from Jaak (and some nice ppl in a c++ help channel
), i translated AVSTrans to C++!
After doing this, it was only a minor step to integrating AVSTrans into my existing eeltrans.ape (which used the VB AVSTrans via COM before).
Now, eeltrans.ape is completely self-contained and can thus be spread along with a preset for example
Also, it can now be used without admin rights and should also run fine on wine.
This APE should do the same as the latest VB version. if it doesnt, or if it crashes or outputs strange errors that the VB version doesnt, plz send me the code piece that causes the problems and I'll see what i can do about it.
The APE also has a code logger that writes all your code into various files in c:\avslog
have fun with it
manual coming soon
The latest VB Version is available here: [link]
[edit]
04.11.05
- major fixup: code saving and displaying works now. crashes less often.
28.06.05
- I fixed and changed the behaviour of global code. You can now have multiple instances of AVSTrans concurrently and even specify global code for each one. The code will simply be concatenated in this case. There should be no more "Instance conflict" dialog boxes or lost code.
30.03.05
- gmegabuf loading should be much faster with this new version and the upcoming version 1.1 of Jheriko's Global Variable Manager
02.02.05
- You can now include external files using "#include filename". Refer to eeltrans.txt for more information and an example.
- log path is now customisable
14.12.04:
- allowed things like a=b=c; (assigns the value of c to a and b)
07.12.04:
- crash bug fixed that would occur if "*)*(*;*)*" was entered, where * is any combination of characters (except brackets) including no characters at all. thx fsk for first reporting this (very vaguely though
)
- some optimisations
06.12.04:
- hopefully everything in the #defines fixed
- fixed a bug that prevented loading the settings when switching from one eeltrans preset to another
04.12.04:
- added documentation
- fixed config dialog grabbing focus when loaded
- fixed a (stupid) bug in the #defines that prevented using token identifiers longer than 1 character
- fixed another bug in the #defines that prevented some uses of the token insertion operator (##) not to work
03.12.04:
- fixed freezing when entering incomplete #defines
- fixed freezing when having bracket errors while using macros
- fixed a stupid bug in the code logger that caused it to crash when entering code with "%" in it
02.12.04:
- improved preset changing behaviour (will not delete the AVSTrans component anymore)
[/edit]
With some help from Jaak (and some nice ppl in a c++ help channel

After doing this, it was only a minor step to integrating AVSTrans into my existing eeltrans.ape (which used the VB AVSTrans via COM before).
Now, eeltrans.ape is completely self-contained and can thus be spread along with a preset for example

Also, it can now be used without admin rights and should also run fine on wine.
This APE should do the same as the latest VB version. if it doesnt, or if it crashes or outputs strange errors that the VB version doesnt, plz send me the code piece that causes the problems and I'll see what i can do about it.
The APE also has a code logger that writes all your code into various files in c:\avslog
have fun with it

manual coming soon

The latest VB Version is available here: [link]
[edit]
04.11.05
- major fixup: code saving and displaying works now. crashes less often.
28.06.05
- I fixed and changed the behaviour of global code. You can now have multiple instances of AVSTrans concurrently and even specify global code for each one. The code will simply be concatenated in this case. There should be no more "Instance conflict" dialog boxes or lost code.
30.03.05
- gmegabuf loading should be much faster with this new version and the upcoming version 1.1 of Jheriko's Global Variable Manager
02.02.05
- You can now include external files using "#include filename". Refer to eeltrans.txt for more information and an example.
- log path is now customisable
14.12.04:
- allowed things like a=b=c; (assigns the value of c to a and b)
07.12.04:
- crash bug fixed that would occur if "*)*(*;*)*" was entered, where * is any combination of characters (except brackets) including no characters at all. thx fsk for first reporting this (very vaguely though

- some optimisations
06.12.04:
- hopefully everything in the #defines fixed

- fixed a bug that prevented loading the settings when switching from one eeltrans preset to another
04.12.04:
- added documentation
- fixed config dialog grabbing focus when loaded
- fixed a (stupid) bug in the #defines that prevented using token identifiers longer than 1 character

- fixed another bug in the #defines that prevented some uses of the token insertion operator (##) not to work
03.12.04:
- fixed freezing when entering incomplete #defines
- fixed freezing when having bracket errors while using macros
- fixed a stupid bug in the code logger that caused it to crash when entering code with "%" in it
02.12.04:
- improved preset changing behaviour (will not delete the AVSTrans component anymore)
[/edit]
Published:
© 2004 - 2021 TomyLobo
Comments43
Join the community to add your comment. Already a deviant? Log In

source code is available at github.com/TomyLobo/eeltrans now, if anyone wants it (probably not)

I made a command line tool.
The source is at the same URL.
Just run "make" in the "AVSTrans_cpp" subdirectory.I also made a travis build for it, so there's a Linux release binary, too:
As Binary releases for Linux go, this might not work on all Linux versions.
I tested it on my WSL (the windows bash thing) which is xenial.
The Travis worker ran on trusty, so that should work too.
In theory, you should be able to compile and run this on any POSIX-compliant system with GCC installed, including Cygwin/Babun on Windows.
With some minor effort, it should run on Visual Studio, too.
Syntax:
./avstrans-cli < eeltrans-code.txt > avs-code.txt

I've had a thought, ya know what'd be nice? If you could translate the preset then save a translated version, for distribution in packs, since at the moment it's still kinda unstable for me... at least on this computer, I know I could use the VB version and do it by hand, but I've got a preset with rather a lot of separate components that all use AVStrans features... (mostly control stuff)

hmmm would it be possible for you to have macros expand inside other macros...
is what I have right now, and there are things that I'm gonna use those in that it wouldbe nice to be able to one of these macros inside another... not to mention that the above would be nicely simplefied to:
#define lin(pos,v1,v2) (pos*v1+v2*(1 - pos))
#define biLin(px,py,v1,v2,v3,v4) (py*(px*v1+(1-px)*v2)+(1-py)*(px*v3+(1-px)*v4))
#define triLin(px,py,pz,v1,v2,v3,v4,v5,v6,v7,v8) ((py*(px*v1+(1-px)*v2)+(1-py)*(px*v3+(1-px)*v4))*pz+(1-pz)*(py*(px*v5+(1-px)*v6)+(1-py)*(px*v7+(1-px)*v8)) )
is what I have right now, and there are things that I'm gonna use those in that it wouldbe nice to be able to one of these macros inside another... not to mention that the above would be nicely simplefied to:
#define lin(pos,v1,v2) (pos*v1+v2*(1 - pos))
#define biLin(px,py,v1,v2,v3,v4) lin(py,lin(px,v1,v2),lin(px,v3,v4))
#define triLin(px,py,pz,v1,v2,v3,v4,v5,v6,v7,v8) lin(pz,biLin(px,py,v1,v2,v3,v4),biLin(px,py,v5,v6,v7,v8))

it is indeed possible, you just have to reverse the order of your #defines
#define triLin(px,py,pz,v1,v2,v3,v4,v5,v6,v7,v8) lin(pz,biLin(px,py,v1,v2,v3,v4),biLin(px,py,v5,v6,v7,v8))
#define biLin(px,py,v1,v2,v3,v4) lin(py,lin(px,v1,v2),lin(px,v3,v4))
#define lin(pos,v1,v2) (pos*v1+v2*(1 - pos))
explanation:
#defines are applied to the code, in their order of appearance in the original code
#define triLin(px,py,pz,v1,v2,v3,v4,v5,v6,v7,v8) lin(pz,biLin(px,py,v1,v2,v3,v4),biLin(px,py,v5,v6,v7,v8))
#define biLin(px,py,v1,v2,v3,v4) lin(py,lin(px,v1,v2),lin(px,v3,v4))
#define lin(pos,v1,v2) (pos*v1+v2*(1 - pos))
explanation:
#defines are applied to the code, in their order of appearance in the original code

C++ is an object-oriented programming language built from the structured language C
its advantages are speed and complete/real OO
Visual Basic (VB) is a pseudo-object-oriented Rapid Application Development language basing on the Syntax of the well-known "BASIC" language
it doesnt have real Object orientation in version 6. the reason i use it anyway is that it makes application development faster by doing all the interface stuff for you.
but if you just want a library and dont need a user interface, you have a problem, since VB is not capable of making a simple DLL and exporting some functions and you must use the component object model (COM) instead. COM is a bitch to use in C++ though, with a hugely complex interface.
its advantages are speed and complete/real OO
Visual Basic (VB) is a pseudo-object-oriented Rapid Application Development language basing on the Syntax of the well-known "BASIC" language
it doesnt have real Object orientation in version 6. the reason i use it anyway is that it makes application development faster by doing all the interface stuff for you.
but if you just want a library and dont need a user interface, you have a problem, since VB is not capable of making a simple DLL and exporting some functions and you must use the component object model (COM) instead. COM is a bitch to use in C++ though, with a hugely complex interface.

been using this for a while now and it really speeds things up, and makes your code much more readable. nice work!
something i'd like to see is some way of simplifying nested ifs, like a case statement or something. also, is it possible to write if statements that drop the 'else' argument? I thought I saw it in an example you gave, but it never seems to work when I try it
something i'd like to see is some way of simplifying nested ifs, like a case statement or something. also, is it possible to write if statements that drop the 'else' argument? I thought I saw it in an example you gave, but it never seems to work when I try it


it's generating code with syntax errors in it for me...
[code]
//these were in the gloabal code on AVSTrans
#define px(INDEX) gmegabuf(INDEX*3);
#define py(INDEX) gmegabuf(INDEX*3+1);
#define pm(INDEX) gmegabuf(INDEX*3+2);
#define pxt(INDEX) megabuf(INDEX*6);
#define pxv(INDEX) megabuf(INDEX*6+1);
#define pyt(INDEX) megabuf(INDEX*6+2);
#define pyv(INDEX) megabuf(INDEX*6+3);
#define pmt(INDEX) megabuf(INDEX*6+4);
#define pmv(INDEX) megabuf(INDEX*6+5);
//these loops are from a superscope that
//updates global variables
//this is from init
numObs=4;
ind=0;
loop(numObs,
px(ind)=0.5*(rand(200)/100-1);
pxt(ind)=0.5*(rand(200)/100-1);
py(ind)=0.5*(rand(200)/100-1);
pyt(ind)=0.5*(rand(200)/100-1);
pxv(ind)=0
yv(ind)=0;
pm(ind)=0;
pmt(ind)=25;
pmv(ind)=0.5;
ind=ind+1;
);
//frame
ind=0;
loop(numObs,
xtmp
xt(ind)-px(ind);
ytmp
yt(ind)-py(ind);
mag=0.4*invsqrt(xtmp*xtmp+ytmp*ytmp);
pxv(ind)
pxv(ind)+xtmp*mag*tspt)/(tspt+1);
pyv(ind)
pyv(ind)+ytmp*mag*tspt)/(tspt+1);
px(ind)
x(ind)+pxv(ind)*delt;
//beat
ind=0;
loop(numObs,
pxt(ind)=0.5*(rand(200)/100-1);
pyt(ind)=0.5*(rand(200)/100-1);
pxv(ind)=0.5*(rand(200)/100-1);
pyv(ind)=0.5*(rand(200)/100-1);
pmt(ind)=25+3*(rand(200)/100-1);
//this loop is from my DM
ind=0;
loop(4,
xt=x-px(ind);yt=y-py(ind);
tmp
m(ind)/(sqr(xt)+sqr(yt));
xsum=xsum+xt*tmp;
ysum=ysum+yt*tmp;
ind=ind+1;
);
ind=ind+1;^M
);^M
py(ind)
y(ind)+pyv(ind)*delt;^M
tmp=sign(pmt(ind)-pm(ind));^M
pmv(ind)
mv(ind)+(tmp-pmv(ind))*0.02*delt;^M
m
m(ind)+pmv(ind)*delt;^M
ind=ind+1;^M
);
[/code]
[code]
//these were in the gloabal code on AVSTrans
#define px(INDEX) gmegabuf(INDEX*3);
#define py(INDEX) gmegabuf(INDEX*3+1);
#define pm(INDEX) gmegabuf(INDEX*3+2);
#define pxt(INDEX) megabuf(INDEX*6);
#define pxv(INDEX) megabuf(INDEX*6+1);
#define pyt(INDEX) megabuf(INDEX*6+2);
#define pyv(INDEX) megabuf(INDEX*6+3);
#define pmt(INDEX) megabuf(INDEX*6+4);
#define pmv(INDEX) megabuf(INDEX*6+5);
//these loops are from a superscope that
//updates global variables
//this is from init
numObs=4;
ind=0;
loop(numObs,
px(ind)=0.5*(rand(200)/100-1);
pxt(ind)=0.5*(rand(200)/100-1);
py(ind)=0.5*(rand(200)/100-1);
pyt(ind)=0.5*(rand(200)/100-1);
pxv(ind)=0

pm(ind)=0;
pmt(ind)=25;
pmv(ind)=0.5;
ind=ind+1;
);
//frame
ind=0;
loop(numObs,
xtmp

ytmp

mag=0.4*invsqrt(xtmp*xtmp+ytmp*ytmp);
pxv(ind)

pyv(ind)

px(ind)

//beat
ind=0;
loop(numObs,
pxt(ind)=0.5*(rand(200)/100-1);
pyt(ind)=0.5*(rand(200)/100-1);
pxv(ind)=0.5*(rand(200)/100-1);
pyv(ind)=0.5*(rand(200)/100-1);
pmt(ind)=25+3*(rand(200)/100-1);
//this loop is from my DM
ind=0;
loop(4,
xt=x-px(ind);yt=y-py(ind);
tmp

xsum=xsum+xt*tmp;
ysum=ysum+yt*tmp;
ind=ind+1;
);
ind=ind+1;^M
);^M
py(ind)

tmp=sign(pmt(ind)-pm(ind));^M
pmv(ind)

m

ind=ind+1;^M
);
[/code]
Join the community to add your comment. Already a deviant? Log In