TomyLobo's avatar

Automated AVSTrans APE (beta)

7 43 6K (1 Today)
By TomyLobo   |   
Published: December 2, 2004
© 2004 - 2020 TomyLobo
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]
Comments43
anonymous's avatar
Join the community to add your comment. Already a deviant? Log In
TomyLobo's avatar
TomyLoboFeatured
source code is available at github.com/TomyLobo/eeltrans now, if anyone wants it (probably not)
TomyLobo's avatar
TomyLoboFeatured
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

MinigunShooter600's avatar
MinigunShooter600Hobbyist Writer
WHYYY!
why is avstrans crashing winamp?
WHY
TomyLobo's avatar
No idea tbh... They probably released a new, incompatible AVS version.
MinigunShooter600's avatar
MinigunShooter600Hobbyist Writer
yeah...
i wish there was a way to convert the eeltrans code to avs code
TomyLobo's avatar
There is, now!
See my featured comment
Spudd86's avatar
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)
TomyLobo's avatar
that's a good idea
all i need for that would be a complete format description for .avs files
Spudd86's avatar
hmmm would it be possible for you to have macros expand inside other macros...

#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))
TomyLobo's avatar
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
dRRew's avatar
Automated AVSTrans APE, wait no.
its TWO years old...damn it, i feel stupid.
TomyLobo's avatar
it's way older than that :)
but before it was like Frankenstein's creature: half VB half C++
dRRew's avatar
god damn, i dont even no what that is.
i dont even no what C++ is.
im guessing its a type of programming thing? ive heard been said a few times.
TomyLobo's avatar
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.
dRRew's avatar
Automated AVSTrans APE is one year old today.
TomyLobo's avatar
well 1.23 beta 4.5 is the latest [u]VB[/u] version
adasha's avatar
adashaProfessional General Artist
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 :(
TomyLobo's avatar
switch statement would be hard to do properly i'm afraid :(
make proposals for the syntax :)

if there is a missing else part, i must've forgotten it, sorry
fragmer's avatar
switch( * ) {
case *:
*;
break;
case *:
*;
break;
default:
*;
}

By the way, it's version 1.25 already, it's time to update the "latest VB Version" link :)
TomyLobo's avatar
1.25? did i miss something? :D
fragmer's avatar
well... my AVS Automation APE says "Using Translator v 1.25.00" so I thought your "latest VB Version" link was outdated - it points to "AVSTrans1.23Beta4.5.zip". Anyway, it works great! :D
adasha's avatar
adashaProfessional General Artist
of course I meant a switch statement. hnnnnngggggghhhh!
Spudd86's avatar
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;pyv(ind)=0;
pm(ind)=0;
pmt(ind)=25;
pmv(ind)=0.5;
ind=ind+1;
);

//frame
ind=0;
loop(numObs,
xtmp=pxt(ind)-px(ind);
ytmp=pyt(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)=p 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=pm(ind)/(sqr(xt)+sqr(yt));
xsum=xsum+xt*tmp;
ysum=ysum+yt*tmp;
ind=ind+1;
);
ind=ind+1;^M
);^M


py(ind)=p y(ind)+pyv(ind)*delt;^M
tmp=sign(pmt(ind)-pm(ind));^M
pmv(ind)=p mv(ind)+(tmp-pmv(ind))*0.02*delt;^M
m=pm(ind)+pmv(ind)*delt;^M
ind=ind+1;^M
);
[/code]
anonymous's avatar
Join the community to add your comment. Already a deviant? Log In