Old 15th September 2008, 20:16   #1
27_super_goats
Junior Member
 
Join Date: Sep 2008
Posts: 11
Evil Variable Gotcha

I just found out after an hour or two of hair-tearing, that variable names have a maximum length of 8 characters. If you declare two variables like:

elephant = 0.5;
elephant_poo = 0.1;

there is really only one variable. Could this be put in the documentation please?
27_super_goats is offline   Reply With Quote
Old 15th September 2008, 20:31   #2
Flexi
wellspring of milk
Major Dude
 
Flexi's Avatar
 
Join Date: Apr 2007
Location: 54.089866,12.11168,18.75
Posts: 2,058
Send a message via ICQ to Flexi
huh? no, long variable names work fine for me - i just checked it. what is your Milkdrop version?

BUT... there's a limit of how many variables you can use - which is quite low at about 20.
Flexi is offline   Reply With Quote
Old 15th September 2008, 20:52   #3
27_super_goats
Junior Member
 
Join Date: Sep 2008
Posts: 11
version 2.0e

Maybe it's only broken for the custom shapes?
Attached Files
File Type: milk long_variable_test.milk (5.0 KB, 272 views)
27_super_goats is offline   Reply With Quote
Old 15th September 2008, 20:58   #4
27_super_goats
Junior Member
 
Join Date: Sep 2008
Posts: 11
Another weird thing is that if you change
x = billy_the;

in my test preset to
x = billy;

it picks up the 0.2 variable! So there are still two variables but it is definitely not correct behaviour.
27_super_goats is offline   Reply With Quote
Old 15th September 2008, 22:44   #5
Flexi
wellspring of milk
Major Dude
 
Flexi's Avatar
 
Join Date: Apr 2007
Location: 54.089866,12.11168,18.75
Posts: 2,058
Send a message via ICQ to Flexi
okay, that's reproducible. but it must have something to do with the underline character. indeed pretty weird, but nothing I'd like to waste time with. maybe you find a hack to pass variable states from one preset to another - who knows

i don't think the script interpreter has changed since Milkdrop1 - if you want to dig deeper into it, you might find some answers in the old source code: http://milkdrop.us/dev.aspx
Flexi is offline   Reply With Quote
Old 16th September 2008, 08:05   #6
fed0r
Senior Member
 
fed0r's Avatar
 
Join Date: Mar 2008
Location: Russia, Saint-Petersburg
Posts: 121
Send a message via ICQ to fed0r
Let's check it out...
fed0r is offline   Reply With Quote
Old 16th September 2008, 13:35   #7
fed0r
Senior Member
 
fed0r's Avatar
 
Join Date: Mar 2008
Location: Russia, Saint-Petersburg
Posts: 121
Send a message via ICQ to fed0r
Shit happens (c)

That's hell ps3! I don't want to launch notepad, that's why i like to use the debugger . Huh, i am a bad code-surfer...
OK if this thread is about <troubleshooting>, here's a template for my new preset. I'll put it in "Cope's finished stuff". I wanna see spirals growing out of every white spot. Need help with arrays and loops... Please look into it, i haven't found any documentation.
Quote:
i am a bad code-surfer...
Attached Files
File Type: milk fed - spiral heck [test 1].milk (6.4 KB, 275 views)
fed0r is offline   Reply With Quote
Old 16th September 2008, 16:05   #8
Flexi
wellspring of milk
Major Dude
 
Flexi's Avatar
 
Join Date: Apr 2007
Location: 54.089866,12.11168,18.75
Posts: 2,058
Send a message via ICQ to Flexi
there are at least two errors within the first loop
code:
for(i=0;i<=15;i+=2)
{
tmp = GetPixel(uv+float2(d[i],d[i+1])); // don't know what you want here: d[_] are of type float2. float2(float2,float2) just cannot work
vals[i/2]=(length(tmp)+lum(tmp))/2; // fixed array out of bound exception
};



interesting stuff, i never even considered using arrays and loops
Flexi is offline   Reply With Quote
Old 16th September 2008, 17:23   #9
fed0r
Senior Member
 
fed0r's Avatar
 
Join Date: Mar 2008
Location: Russia, Saint-Petersburg
Posts: 121
Send a message via ICQ to fed0r
Thanks. I was dizzy, really!
a) There was float d[16] in the beginning, so
tmp = GetPixel(uv+float2(d[i],d[i+1]));
should be meant here as
tmp = GetPixel(uv+d[i]);
b)That was an invisible bug to me... BIG THANKS about this err!
for(i=0;i<=7;i++){...vals[i+1]...} //i+1>7!!!
PS. that's not "vals[i/2]..." - that is "vals[i]..."
c)Fixed. >96 instr. Can I ask you for PS3 test, please?
Attached Files
File Type: milk fed - spiral heck [test 2].milk (6.5 KB, 253 views)
fed0r is offline   Reply With Quote
Old 16th September 2008, 18:49   #10
Flexi
wellspring of milk
Major Dude
 
Flexi's Avatar
 
Join Date: Apr 2007
Location: 54.089866,12.11168,18.75
Posts: 2,058
Send a message via ICQ to Flexi
ps3? sry i'm out
Flexi is offline   Reply With Quote
Old 16th September 2008, 20:57   #11
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 856
Well, it's white screen to me !
Nitorami is offline   Reply With Quote
Old 16th September 2008, 21:33   #12
27_super_goats
Junior Member
 
Join Date: Sep 2008
Posts: 11
Thanks, Flexi, I feel vindicated now. I don't expect anybody to fix it but thought it was worth flagging up. I hope the latest source code gets opened up soon. Damn I might even submit a fix myself then.
27_super_goats is offline   Reply With Quote
Old 17th September 2008, 11:11   #13
fed0r
Senior Member
 
fed0r's Avatar
 
Join Date: Mar 2008
Location: Russia, Saint-Petersburg
Posts: 121
Send a message via ICQ to fed0r
Thx Martin...
foolish err:
...uv+d[i]... REALLY should be
...uv+d[i]*texsize.zw
PS: 27sg, I'm looking into the milkdrop 1.05 source at now. The code interpreter is 'evallib' module. That's a true place where the bug is.
Attached Files
File Type: milk fed - spiral heck [test 3].milk (6.5 KB, 280 views)
fed0r is offline   Reply With Quote
Old 17th September 2008, 16:50   #14
fed0r
Senior Member
 
fed0r's Avatar
 
Join Date: Mar 2008
Location: Russia, Saint-Petersburg
Posts: 121
Send a message via ICQ to fed0r
The Instruction

Expression evaluation library v1.0 - by lone
--------------------------------------------


How to use
~~~~~~~~~~


¦ resetVars
-----------

void resetVars(void);

Resets the variables table. It is necessary to call it prior to evaluate your first
expression or variables contents may be random instead of zero


¦ evaluate
----------

double evaluate(char *expression, int *col);

Evaluates an expression and returns the result.
If a syntax error was encountered during the parsing of the expression, then col will
be non-null and col-1 will be the index of the char which triggered the error.


Limitations
~~~~~~~~~~~

¦ you can set only up to 1024 variables.
¦ only decimal and hexadecimal bases available
¦ operators are limited to :
+ - / * % & |
¦ functions are limited to :
sin, cos, tan,
asin, acos, atan,
atan2, sqr, sqrt,
pow, exp, log, log10


Some examples
~~~~~~~~~~~~~

- assignments :

pi=3.1415927
a=atan2(cos(pi/4),2)

- direct evaluations :

cos(pi/4)
sin(45)

- base notations :

3bh (this is 0x3B)
17d (this is 17)
17dh (this is 0x17D)


Adding new functions
~~~~~~~~~~~~~~~~~~~~

The file EVAL.C contains the functions table (fnTable). Just add an entry with the name,
the number of parameters, and a pointer to the function body. Implement the body and
you're done. If your function ahs more than 2 parameters, you'll need to extend the grammar
description file (CAL.Y) to add the FUNCTION3 (and eventually subsequent) token(s) and
parsing informations.

SCAN.L & CAL.Y
~~~~~~~~~~~~~~

SCAN.L contains description for the lexical analyzer generator (LEX). Use makel.bat to rebuild
LEXTAB.C
CAL.Y contains the LALR formal grammar description for the parser generator (BISON). Use makey.bat
to rebuild CAL_TAB.C


Compiling
~~~~~~~~~

Just include all source files to your project, and include EVAL.H into your main source code.

License
-------
Copyright 2005 Nullsoft, Inc.
All rights reserved.
..........................
... blah blah licence stuff
-----------------------------------------
Don't you think he's wrong with the 1024 vars available? It seems that we have the code generation mechanism unoptimized.
fed0r is offline   Reply With Quote
Old 17th September 2008, 17:11   #15
fed0r
Senior Member
 
fed0r's Avatar
 
Join Date: Mar 2008
Location: Russia, Saint-Petersburg
Posts: 121
Send a message via ICQ to fed0r
And the ps2

ps2 version for testing
Attached Files
File Type: milk long_variable_test_ps2.milk (5.0 KB, 295 views)
fed0r is offline   Reply With Quote
Old 17th September 2008, 17:14   #16
Flexi
wellspring of milk
Major Dude
 
Flexi's Avatar
 
Join Date: Apr 2007
Location: 54.089866,12.11168,18.75
Posts: 2,058
Send a message via ICQ to Flexi
according to redi jedi, the maximum amount of variables is set somewhere in a header file as a constant. i have not looked into the source yet, i'm still waiting for the MD2.0 sources...
redi-jedi also stated, that it is quite easy to include new functions with the script language
Flexi is offline   Reply With Quote
Old 18th September 2008, 08:44   #17
fed0r
Senior Member
 
fed0r's Avatar
 
Join Date: Mar 2008
Location: Russia, Saint-Petersburg
Posts: 121
Send a message via ICQ to fed0r
Found some bugs in MD2. Firstly, it seems to determine my videocard has no pixel shader support. Also, when trying to upgrade ps1.1 presets - MD shows a strange message:
This preset uses the highest pixel shader version (0) supported by your graphics chip.

Nope. "The highest pixel shader version supported by my graphics chip" is 3 (2 because ATI+MD2+ps3=CRAP).
Furthermore, if you press 'y' after this, MD closes with an error msg.
There is no field in the settings panel to set the ps model, so i have no ideas what happened. Defaults don't help also. Trying to reinstall at now.
PS: Have anybody tried my spiral heck test 3? I just can't take these ps3's anymore.

Last edited by fed0r; 18th September 2008 at 09:29.
fed0r is offline   Reply With Quote
Old 18th September 2008, 10:58   #18
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 856
Geiss' preset authoring guide says variables used in the per frame equations are limited to 30:

"You can also make up to 30 of your own variables."

This seems to be independant of what evallib could handle. Im my own experience, the limitation to 30 is fact and you will get very odd results when exceeding this limit.

As to spiral heck 3: Only see some random dot noise before it fades to white.
Nitorami is offline   Reply With Quote
Old 18th September 2008, 11:17   #19
fed0r
Senior Member
 
fed0r's Avatar
 
Join Date: Mar 2008
Location: Russia, Saint-Petersburg
Posts: 121
Send a message via ICQ to fed0r
Fixed my ps0 bug. I'm back again

Hey Martin, big thanks.
I'm not going to do ps3 any more until I'll get a new fix/card.
fed0r is offline   Reply With Quote
Old 23rd September 2008, 12:11   #20
redi jedi
Will code for food
 
Join Date: Mar 2005
Location: orlando
Posts: 521
For as long as I can remember var names are "limited" to 8 chars, so for instance, in the code block:
someLongVarName1 = 5;
someLongVarName2 = 10;
monitor = someLongVarName1;
Monitor should display 10 instead of 5 as would be expected, no error, no warning it simply ignores all characters after the first 8, which is why it still works in some instances, because If i had written:
someLongVarName1 = 5;
monitor = someLongVarName1;
someLongVarName2 = 10;
It would work as expected.


orig limit was 30, my version upped it to 40 or 50, and not sure what he did

Blah!
redi jedi is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > MilkDrop > MilkDrop Presets

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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