MilkDrop Preset Authoring

From Winamp Developer Wiki
Revision as of 14:52, 10 June 2009 by Culix (Talk | contribs)

Jump to: navigation, search

MILKDROP preset authoring guide

Note that there is another, quite comprehensive, Preset Authoring Guide available on the web at http://www.milkdrop.co.uk/, which is continually updated and expanded through the hard work of a few dedicated preset authors. Whereas this guide (the one you are currently viewing) gives the bare technical specifications for writing your own presets, the guide at milkdrop.co.uk 'starts at the beginning' and walks you through all of the mathematics and subtleties of 'rolling your own', explaining things in great detail. The guide at milkdrop.co.uk is very highly recommended to anyone who wishes to learn more about creating their own presets. Also, there is a Pixel shader guide on this wiki.

About Presets

When you watch MilkDrop, you are watching a series of Presets. Each one has its own look and feel, draws the sound waves in a particular way, and has certain motions to it. After some time, you will see a short blend transition, and then you will be watching a new preset.

A single 'preset' is a collection of parameters that tell MilkDrop how to draw the wave, how to warp the image around, and so on. MilkDrop ships with over 100 built-in presets, each one having a distinct look and feel to it.

Using MilkDrop's built-in "preset-editing menu" (the M key), you can edit presets on the fly, on-screen, from within the program. You can make slight adjustments to existing presets, then save over them; or you can change lots of things, so the preset doesn't look anything like the original, and then save it under a new name. You can even write insane new mathematical equations, of your own imagination, into your preset files and come up with things that MilkDrop has never done before!

Each preset is saved as a file with the ".milk" extension, so you can easily send them to your friends or post them on the web. You can also go to http://www.nullsoft.com/free/milkdrop and then jump to the "preset sharing forum" to see what other people have come up with, or post your own cool, new presets. milkdrop.co.uk/ is another great place to download collections of presets made by others like yourself.

Preset Authoring - Basic

You can edit the properties of the current preset by hitting 'M', which brings up the "preset-editing menu". From this menu you can use the up and down arrow keys to select an item. Press the RIGHT arrow key to move forward through the menu and select the item (note: you can also hit SPACE or RETURN to do this); ***press the LEFT arrow key to go back to the previous menu.***

Pressing 'M' while the menu is already showing will hide the menu; pressing ESCAPE will do the same thing. Press 'M' again to bring the menu back.

Once you've reached an item on the menu whose value can be edited, use the UP and DOWN arrow keys to increase or decrease its value, respectively. Changes will register immediately. Use PAGE UP and PAGE DOWN to increase the value more quickly. Hold down SHIFT and use the UP/DOWN arrow keys to change the value very slowly. Hit RETURN To keep the new value, or ESC to abort the change.

If the item you're editing is a text string, you can use the arrow keys to move around. The Insert key can be used to toggle between insert and overtype modes. You can hold shift and use the arrow keys (home, end, left, right) to make a selection, which will be identified by brackets []. You can then use CTRL-C or CTRL-X to copy or cut text. CTRL-P pastes. When finished editing, hit RETURN To keep the new string, or ESC to abort the change.

You'll want to get into the habit of using SCROLL LOCK whenever you're making changes to a preset that you intend to save; otherwise, MilkDrop is sure to move you along to a new (random) preset, over time. When the menus are showing, the preset is automatically temporarily locked, but BE CAREFUL - if you're not also using SCROLL LOCK, then 0.1 seconds after you hide the menu to take a look at your new masterpiece, MilkDrop might load a random new preset on you, and you'd lose your changes! And you might then ask me: "how large is large?" And I will tell you: "thirty."

   There are also some hotkeys that will allow you to change certain
   common parameters to the current preset.  These are listed below.
   
   MOTION
       i/I - zoom in/out
       [ / ] - push motion to the left/right (dx)
       { / } - push motion up/down (dy)
       < / > - rotate left/right (rot)
       o/O - shrink/grow the amplitude of the warp effect
   WAVEFORM
       W   - cycle through waveforms
       j/J - scale waveform down/up
       e/E - make the waveform more transparent/more solid
   BRIGHTNESS **
       g/G - decrease, increase gamma (brightness) **
   VIDEO ECHO effect **
       q/Q - scale 2nd graphics layer down/up **
       F - flip 2nd graphics layer (cycles through 4 fixed orientations) **
   ** these keys only have an effect if you are running a 
      MilkDrop 1-era preset.  In MilkDrop 2-era presets,
      these values are embedded in the shader, so you need
      to go into the composite shader and tweak the code.

Preset Authoring - Advanced

This section describes how to use the 'per-frame' and 'per-vertex' equations to develop unique new presets.


PER-FRAME EQUATIONS

When you hit 'm' to show the preset-editing menu, several items show up. If you explore the sub-menus, you'll see that all of the properties that make up the preset you're currently viewing are there. The values you can specify here (such as zoom amount, rotation amount, wave color, etc.) are all static values, meaning that they don't change in time. For example, take the 'zoom amount' option under the 'motion' submenu. If this value is 1.0, there is no zoom. If the value is 1.01, the image zooms in 1% every frame. If the value is 1.10, the image zooms in 10% every frame. If the value is 0.9, the image zooms out 10% every frame; and so on.

However, presets get far more interesting if you can take these parameters (such as the zoom amount) and animate them (make them change over time). For example, if you could take the 'zoom amount' parameter and make it oscillate (vary) between 0.9 and 1.1 over time, the image would cyclically zoom in and out, in time.

You can do this - by writing 'per-frame' and 'per-vertex' equations. Let's start with 'per-frame' equations. These are executed once per frame. So, if you were to type the following equation in:

zoom = zoom + 0.1*sin(time);
   

...then the zoom amount would oscillate between 0.9 and 1.1 over time. (Recall from your geometry classes that sin() returns a value between -1 and 1.) The equation says: "take the static value of 'zoom', then replace it with that value, plus some variation." This particular equation would oscillate (cycle) every 6.28 seconds, since the sin() function's period is 6.28 (PI*2) seconds. If you wanted it to make it cycle every 2 seconds, you could use:

zoom = zoom + 0.1*sin(time*3.14);
   

Now, let's say you wanted to make the color of the waveform (sound wave) that gets plotted on the screen vary through time. The color is defined by three values, one for each of the main color components (red, green, and blue), each in the range 0 to 1 (0 is dark, 1 is full intensity). You could use something like this:

wave_r = wave_r + 0.5*sin(time*1.13);
wave_g = wave_g + 0.5*sin(time*1.23);
wave_b = wave_b + 0.5*sin(time*1.33);
   

It's nice to stagger the frequencies (1.13, 1.23, and 1.33) of the sine functions for the red, green, and blue color components of the wave so that they cycle at different rates, to avoid them always being all the same (which would create a greyscale wave).

Here is a full list of the variables available for writing per-frame equations:

   NAME       WRITABLE?  RANGE  DESCRIPTION
   ----       ---------  -----  -----------                                                                   
   zoom           yes    >0     controls inward/outward motion.  0.9=zoom out 10% per frame, 1.0=no zoom, 1.1=zoom in 10%
   zoomexp        yes    >0     controls the curvature of the zoom; 1=normal
   rot            yes           controls the amount of rotation.  0=none, 0.1=slightly right, -0.1=slightly clockwise, 0.1=CCW
   warp           yes    >0     controls the magnitude of the warping; 0=none, 1=normal, 2=major warping...
   cx             yes    0..1   controls where the center of rotation and stretching is, horizontally.  0=left, 0.5=center, 1=right
   cy             yes    0..1   controls where the center of rotation and stretching is, vertically.  0=top, 0.5=center, 1=bottom
   dx             yes           controls amount of constant horizontal motion; -0.01 = move left 1% per frame, 0=none, 0.01 = move right 1%
   dy             yes           controls amount of constant vertical motion; -0.01 = move up 1% per frame, 0=none, 0.01 = move down 1%
   sx             yes    >0     controls amount of constant horizontal stretching; 0.99=shrink 1%, 1=normal, 1.01=stretch 1%           
   sy             yes    >0     controls amount of constant vertical stretching; 0.99=shrink 1%, 1=normal, 1.01=stretch 1%             
   wave_mode      yes    0,1,2,3,4,5,6,7  controls which of the 8 types of waveform is drawn
   wave_x         yes    0..1   position of the waveform: 0 = far left edge of screen, 0.5 = center, 1 = far right
   wave_y         yes    0..1   position of the waveform: 0 = very bottom of screen, 0.5 = center, 1 = top
   wave_r         yes    0..1   amount of red color in the wave (0..1),
   wave_g         yes    0..1   amount of green color in the wave (0..1)    
   wave_b         yes    0..1   amount of blue color in the wave (0..1)    
   wave_a         yes    0..1   opacity of the wave (0..1) [0=transparent, 1=opaque]
   wave_mystery   yes    -1..1  what this parameter does is a mystery.  (honestly, though, this value does different things for each waveform; for example, it could control angle at which the waveform was drawn.)
   wave_usedots   yes    0/1    if 1, the waveform is drawn as dots (instead of lines)
   wave_thick     yes    0/1    if 1, the waveform's lines (or dots) are drawn with double thickness
   wave_additive  yes    0/1    if 1, the wave is drawn additively, saturating the image at white
   wave_brighten  yes    0/1    if 1, all 3 r/g/b colors will be scaled up until at least one reaches 1.0
   ob_size        yes    0..0.5 thickness of the outer border drawn at the edges of the screen every frame
   ob_r           yes    0..1   amount of red color in the outer border
   ob_g           yes    0..1   amount of green color in the outer border
   ob_b           yes    0..1   amount of blue color in the outer border
   ob_a           yes    0..1   opacity of the outer border (0=transparent, 1=opaque)
   ib_size        yes    0..0.5 thickness of the inner border drawn at the edges of the screen every frame
   ib_r           yes    0..1   amount of red color in the inner border                                   
   ib_g           yes    0..1   amount of green color in the inner border                                 
   ib_b           yes    0..1   amount of blue color in the inner border                                  
   ib_a           yes    0..1   opacity of the inner border (0=transparent, 1=opaque)                     
   mv_r           yes    0..1   amount of red color in the motion vectors
   mv_g           yes    0..1   amount of green color in the motion vectors
   mv_b           yes    0..1   amount of blue color in the motion vectors
   mv_a           yes    0..1   opacity of the motion vectors (0=transparent, 1=opaque)                     
   mv_x           yes    0..64  the number of motion vectors in the X direction
   mv_y           yes    0..48  the number of motion vectors in the Y direction
   mv_l           yes    0..5   the length of the motion vectors (0=no trail, 1=normal, 2=double...)
   mv_dx          yes    -1..1  horizontal placement offset of the motion vectors
   mv_dy          yes    -1..1  vertical placement offset of the motion vectors
   decay          yes    0..1   controls the eventual fade to black; 1=no fade, 0.9=strong fade, 0.98=recommended
   gamma          yes    >0     controls display brightness; 1=normal, 2=double, 3=triple, etc.
   echo_zoom      yes    >0     controls the size of the second graphics layer
   echo_alpha     yes    >0     controls the opacity of the second graphics layer; 0=transparent (off), 0.5=half-mix, 1=opaque
   echo_orient    yes    0,1,2,3 selects an orientation for the second graphics layer.  0=normal, 1=flip on x, 2=flip on y, 3=flip on both
   darken_center  yes    0/1    if 1, help keeps the image from getting too bright by continually dimming the center point
   wrap           yes    0/1    sets whether or not screen elements can drift off of one side and onto the other
   invert         yes    0/1    inverts the colors in the image
   brighten       yes    0/1    brightens the darker parts of the image (non-linear; square root filter)
   darken         yes    0/1    darkens the brighter parts of the image (non-linear; squaring filter)
   solarize       yes    0/1    emphasizes mid-range colors
   monitor        yes    any    set this value for debugging your preset code; if you hit the 'N' key, 
                                   the value of 'monitor' will be posted in the upper-right corner of milkdrop.
                                   for example, setting "monitor = q3;" would let you keep an eye on q3's value.
       
   time           NO     >0     retrieves the current time, in seconds, since MilkDrop started running
   fps            NO     >0     retrieves the current framerate, in frames per second.
   frame          NO            retrieves the number of frames of animation elapsed since the program started
   progress       NO     0..1   progress through the current preset; if preset was just loaded, this is closer to 0; if preset is about to end, this is closer to 1.
                                  -note that if Scroll Lock is on, 'progress' will freeze!
                  
   bass           NO     >0     retrieves the current amount of bass.  1 is normal; below ~0.7 is quiet; above ~1.3 is loud bass
   mid            NO     >0       -same, but for mids (middle frequencies)
   treb           NO     >0       -same, but for treble (high) frequencies
   bass_att       NO     >0     retrieves an attenuated reading on the bass, meaning that it is damped in time and doesn't change so rapidly.
   mid_att        NO     >0       -same, but for mids (middle frequencies)
   treb_att       NO     >0       -same, but for treble (high) frequencies
   meshx          NO     8-128  tells you the user's mesh size in the X direction.  always an integer value.
   meshy          NO     6-96   tells you the user's mesh size in the Y direction.  always an integer value.
   pixelsx        NO     16-4096 width of the viz window, in pixels.  If Canvas Stretch is on, this is the pre-stretched size.  (same as "texsize.x" for shaders)
   pixelsy        NO     16-4096 height of the viz window, in pixels.  If Canvas Stretch is on, this is the pre-stretched size.  (same as "texsize.y" for shaders)
   aspectx        NO     >0     multiply an x-coordinate by this to make the preset look the same at any aspect (window height:width) ratio.
                                  -value: if widescreen, 1; if window is tall, h/w.
   aspecty        NO     >0     multiply a y-coordinate by this to make the preset look the same at any aspect (window height:width) ratio.
                                  -value: if widescreen, w/h; if window is tall, 1.
   
   blur1_min      yes    0..1   Normally these are set to 0 (min) and 1 (max).
   blur2_min      yes    0..1   You can clamp the values in the blur texture to a tighter
   blur3_min      yes    0..1     range, though.  
   blur1_max      yes    0..1   This will increase the precision in the blur textures,
   blur2_max      yes    0..1     but you run the risk of clamping values to your min/max.
   blur3_max      yes    0..1   If you use the GetBlur1() .. GetBlur3() functions to sample
   blur1_edge_darken yes 0..1     the blur texture, they will automatically "unpack" the
                                  values for you in the end!
   
   q1             yes    any    } Used to carry values along a chain                                         
   q2             yes    any    }  from the preset init code,                                                
   q3             yes    any    }  to the preset per-frame code, then on                                     
   q4             yes    any    }    to the preset per-vertex code;                                          
   q5             yes    any    }    or to the custom shape per-frame code,                                  
   q6             yes    any    }    or to the custom wave per-frame code,                                   
   q7             yes    any    }      then to the custom wave per-vertex code;                              
   ...                          }    or to the [pixel] shader code.                                          
   q31            yes    any    } Click here to see a diagram for the Q vars.
   q32            yes    any    } 


   Some of the variables are read-only, meaning that you shouldn't change
   their values them through the equations.  You can; it won't stop you; 
   but the results are unpredictable.
           
   You can also make up to 30 of your own variables.  For example:
   
       my_volume = (bass + mid + treb)/3;
       zoom = zoom + 0.1*(my_volume - 1);
   This would make the zoom amount increase when the music is loud,
   and decrease when the music is quiet.  
   
   HOWEVER, custom variables do not carry over from per-frame equations
   to per-vertex equations; if you set a custom variable's value in the
   per-frame equations, and try to read it in the per-vertex equations,
   you will not get the correct value.  Instead, you have to "bridge the
   gap" using 32 special variables: q1 through q32.  This is usually only
   used when you want to precompute some custom values in the per-frame 
   equations for later use in the per-vertex equations (or for use in
   the pixel shaders).  For a good example of this, see the 'dynamic swirls' 
   preset.  See below for more information on q1-q32.

PER-VERTEX EQUATIONS

   So far we've discussed only how to change parameters based on
   time.  What if you wanted to also vary a parameter, such as the
   zoom amount, in different ways, for different locations on the
   screen?  For example, normally, the result of the 'zoom' parameter
   is to just do a flat zoom.  This doesn't look very realistic, 
   because you don't see any perspective in the zoom.  It would be
   better if we could give a unique zoom amount to each pixel on 
   the screen; we could make the pixels far away from the center
   zoom more, and this would give it more perspective.  In order
   to do this, we use "per-vertex" equations, instead of per-frame
   equations.
   
   The code for this per-vertex equation is simple:
   
       zoom = zoom + rad*0.1;
       
   Where 'rad' is the radius of the pixel if it were cast into
   polar coordinates; from another perspective, 'rad' is the distance 
   of the pixel from the center of the screen.  'rad is zero at the
   center, and 1 at the corners.  So if we run the above code,
   the image will be zoomed into 10% more at the edges of the screen
   than at the center.
   
   The per-vertex equations are really just like the per-frame equations,
   except for a variables.  The following variables are available
   exclusively to per-vertex equations (and not to per-frame equations):
   
   NAME   WRITEABLE? RANGE    DESCRIPTION
   ----   ---------- -----    -----------                                                                   
   x          NO     0..1     retrieves the x-position of the current pixel.  At the very left edge of the screen this would be 0; in the middle, 0.5; and at the right, 1.   
   y          NO     0..1     retrieves the y-position of the current pixel.  At the very top edge of the screen this would be 0; in the middle, 0.5; and at the bottom, 1.   
   rad        NO     0..1     retrives the distance of the pixel from the center of the screen.  At the center of the screen this will be zero, and at the corners, 1.  
                                 (The middle of the edges will be 0.707 (half of the square root of 2).
   ang        NO     0..6.28  retrieves the angle of the current pixel, with respect to the center of the screen.  
                                 If the point is to the right of the center, this is zero; above it, it is PI/2 (1.57); to the left, it is PI (3.14); and below, it is 4.71 (PI*3/2).  
                                 If it is just a dab below being directly to the right of the center of the screen, the value will approach 6.28 (PI*2).  
                                 (note: this is simply the arctangent of y over x, precomputed for you.)
   
   zoom       yes    >0       controls inward/outward motion.  0.9=zoom out 10% per frame, 1.0=no zoom, 1.1=zoom in 10%
   zoomexp    yes    >0       controls the curvature of the zoom; 1=normal
   rot        yes             controls the amount of rotation.  0=none, 0.1=slightly right, -0.1=slightly clockwise, 0.1=CCW
   warp       yes    >0       controls the magnitude of the warping; 0=none, 1=normal, 2=major warping...
   cx         yes    0..1     controls where the center of rotation and stretching is, horizontally.  0=left, 0.5=center, 1=right
   cy         yes    0..1     controls where the center of rotation and stretching is, vertically.  0=top, 0.5=center, 1=bottom
   dx         yes             controls amount of constant horizontal motion; -0.01 = move left 1% per frame, 0=none, 0.01 = move right 1%
   dy         yes             controls amount of constant vertical motion; -0.01 = move up 1% per frame, 0=none, 0.01 = move down 1%
   sx         yes    >0       controls amount of constant horizontal stretching; 0.99=shrink 1%, 1=normal, 1.01=stretch 1%           
   sy         yes    >0       controls amount of constant vertical stretching; 0.99=shrink 1%, 1=normal, 1.01=stretch 1%             
   
   time       NO     >0       retrieves the current time, in seconds, since MilkDrop started running
   fps        NO     >0       retrieves the current framerate, in frames per second.
   frame      NO              retrieves the number of frames of animation elapsed since the program started
   progress   NO     0..1     progress through the current preset; if preset was just loaded, this is closer to 0; if preset is about to end, this is closer to 1.
                                -note that if Scroll Lock is on, 'progress' will freeze!
   bass       NO     >0       retrieves the current amount of bass.  1 is normal; below ~0.7 is quiet; above ~1.3 is loud bass
   mid        NO     >0         -same, but for mids (middle frequencies)
   treb       NO     >0         -same, but for treble (high) frequencies
   bass_att   NO     >0       retrieves an attenuated reading on the bass, meaning that it is damped in time and doesn't change so rapidly.
   mid_att    NO     >0         -same, but for mids (middle frequencies)
   treb_att   NO     >0         -same, but for treble (high) frequencies
   meshx      NO     8-192    tells you the user's mesh size in the X direction.  always an integer value.
   meshy      NO     6-144    tells you the user's mesh size in the Y direction.  always an integer value.
   pixelsx    NO     16-4096  width of the viz window, in pixels.  If Canvas Stretch is on, this is the pre-stretched size.  (same as "texsize.x" for shaders)
   pixelsy    NO     16-4096  height of the viz window, in pixels.  If Canvas Stretch is on, this is the pre-stretched size.  (same as "texsize.y" for shaders)
   aspectx    NO     >0     multiply an x-coordinate by this to make the preset look the same at any aspect (window height:width) ratio.
                              -value: if widescreen, 1; if window is tall, h/w.
   aspecty    NO     >0     multiply a y-coordinate by this to make the preset look the same at any aspect (window height:width) ratio.
                              -value: if widescreen, w/h; if window is tall, 1.
           
   q1         yes    any      } Used to carry values along a chain           
   q2         yes    any      }  from the preset init code,                        
   q3         yes    any      }  to the preset per-frame code, then on             
   q4         yes    any      }    to the preset per-vertex code;            
   q5         yes    any      }    or to the custom shape per-frame code,          
   q6         yes    any      }    or to the custom wave per-frame code,      
   q7         yes    any      }      then to the custom wave per-vertex code;
   ...                        }    or to the [pixel] shader code.            
   q31        yes    any      } Click here to see a diagram for the Q vars.
   q32        yes    any      } 
   
   
   The main reason for distinction between per-frame and per-vertex equations
   is simple: SPEED.  If you have a per-vertex equation that doesn't make use
   of the x, y, rad, or ang variables, then there's no reason for it to be
   executed per-vertex; it could be executed once per frame, and the result
   would be the same.  So, here's a maxim to write on the wall:
   
       "If a per-vertex equation doesn't use at least one of the variables
        { x, y, rad, ang }, then it should be actually be a per-frame 
        equation."
   
   You might be wondering how on earth all these formulas could be computed
   for every pixel on the screen, every frame, and still yield a high frame
   rate.  Well, that's the magic of the hamster.  And the fact that it really
   does the processing only at certain points on the screen, then interpolates
   the results across the space between the points.  In the config panel,
   the "mesh size" option defines how many points (in X and Y) there are at
   which the per-vertex equations are actually computed.  When you crank this
   option up, you start eating up CPU cycles rather quickly.



VARIABLE POOLS; DECLARING YOUR OWN VARIABLES; PERSISTENCE OF VALUES

   -----------------------
   Declaring and using your own variables is easy - in some bit of code 
   (init equations, per-frame equations, etc.) you just write something like
   the following:
   
       billy = 5.3;
   
   This creates a variable called 'billy' and sets its value to 5.3.  You can
   then freely read and/or modify the value of 'billy' within that section
   of code.
   
   However, sometimes it is desireable to create (really, initialize) a variable 
   in an "init" equations, then use and/or update it in the "per-frame" equations.
   You can always do this, because paired init and per-frame equations
   share the same variable pool.  In addition, the values of user-defined
   variables will persist from frame to frame.
   
   There are three variable "pools" in MilkDrop:
     1. preset init code + preset per-frame code
     2. custom wave init + custom wave per-frame code
     3. custom shape init + custom shape per-frame code
   
   So, you can probably guess that if you declare a variable in the preset
   init code, you can then read it in the preset per-frame code.  You can
   also write to it (update it), and its value will persist to the next
   frame.  All three pools work this way.
   As explained, though, you can't read the value of 'billy' in when in another 
   variable pool.  (This is intentional, and keeps MilkDrop running nice and 
   fast.)  If you want to pass values around between variable pools, you need 
   to use a set of special variables: q1, q2, q3, etc. on up to q32.  See
   the next section for details on how they work and how to properly use them.
   Just remember: the Q variables (and later, the T variables) are the only ones 
   that you can use to "jump" between (carry values between) variable pools.
   
   You might notice that there are two other types of equations that weren't 
   listed above.  They are:
   
     * preset per-vertex code
     * custom wave per-point code
   
   For these two code sections, persistent values don't really make sense,
   because there is no way to properly initialize them.  Any user-defined
   variables in these code sections should just be treated as scratch
   variables, not persisting from frame to frame, from vertex to vertex,
   or from point to point (even though technically, they will... but it
   probably won't be what you want).  The only thing that really makes sense
   here is when you want to carry values along from point to point as
   you run the custom wave per-point code; to do this, use q1-q32.  (See
   the next section for a more detailed explanation.)  



PRESET INIT CODE; CARRYING VALUES BETWEEN VARIABLE POOLS, USING q1-q32

   As we've just seen, you can't normally pass values around between variable 
   pools.  However, there is one mechanism for bridging this gap: the 'Q'
   variables.  They are named q1, q2, q3, and so on, through q32.  Their
   main function is to bridge the gap between various variable pools.
   
   In MilkDrop 1.03 and later, you can write code that is executed only once,
   when a preset is loaded (switched to).  This 'preset initialization' code 
   does two useful things:
     
     1. It allows you to set the initial value of your own (user-defined) 
        variables (such as 'my_variable'), as just explained.  
        
     2. It allows you to write the default ("sticky") values for q1, q2, q3... 
        through q32.  Whatever these values end up at after the init code, 
        those are the values that q1-q32 will be reset to at the start of 
        each frame (...the input to the per-frame equations).  If the
        per-frame equations change the values of q1-q32, those new values will
        propagate on to other variable pools (see the diagram below), but on
        the next frame, the values will be reset to the original "sticky" 
        defaults.
        
   See the flow chart below for a brief, and complete, glance at how the values
   of the Q variables flow throughout MilkDrop.
   
   
   Let's walk through the flow of the chart.  
   
   If you write to the values of q1..q32 from the "preset init code", the values 
   you write will become the new 'base values' to which q1..q32 are initialized 
   at the start of each frame, for the per-frame code.  So when you access (read) 
   q1-q32 in the per-frame code, you'll get the values that were *initially* set -
   over and over, every frame.  You can then modify them (or not) in the per-frame 
   code, and the (possibly modified values) will then be readable by the per-vertex 
   code - as well as by all pixel shader code, and others.  However, any modified 
   values will not persist to the next frame; they will be reset again, at the 
   start of the next frame, to the values they had at the end of the preset init 
   code.
   In the per-vertex code, the q1-q32 values start (for the first vertex 
   in any frame) as the values they had at the end of the per-frame code.  If you 
   modify q1-q32 in the per-vertex code, those modified values will carry over 
   from vertex to vertex.  (This isn't a very desireable effect; you should avoid 
   writing to the Q variables from the per-vertex equations.)  Next frame, they 
   will be reset to whatever value they had at the end of the [next frame's 
   execution of the] per-frame code.  (It's all in the diagram... look at that, 
   and you'll just get it.)
   There is one trick here.  You might notice that the custom wave/shape
   init boxes are missing from the diagram.  That's because the q
   variables coming out of them don't go anywhere.  The Q values that come
   into the per-frame wave/shape equations come from the preset per-frame
   equations, as you can see.  But, just to humor you: in the wave/shape init code, 
   the Q values coming in are the results from the preset init code.  Any Q values 
   you write to there (in the wave/shape init code) will be meaningless; although
   you can write to (initialize) your own custom variables, and read those in 
   later, in the wave/shape per-frame equations!  So, really, you can still route
   data that way, if you really want to.
       
   Side note: when you edit the preset init code and apply it (by hitting 
   CTRL+ENTER), the init code will re-execute immediately.  However, when you 
   edit the regular per-frame/per-vertex code and hit CTRL+ENTER, the preset init 
   code will NOT be re-executed; the results of the last execution will persist.
   If you change per-frame/per-vertex code and want to re-execute the initialization
   code (i.e. to randomize it or reset the preset), you'll have to save the preset
   and then re-load it.
   (Historical note: nothing here has changed since MilkDrop 1; these diagrams were
   just re-designed to be much simpler to read.  Actually, there was a bug in 
   the old diagrams that is now fixed: on frame 0, they showed the Q values 
   going straight from the (frame 0!?) per-frame code, into the custom 
   wave/shape init code.  On frame 0, those Q values actually come straight from 
   the preset init code.  HOWEVER, they are virtually useless, as discussed above.)



CUSTOM SHAPES AND WAVES

   ----------------------
   As of MilkDrop 1.04, two new features are available: custom shapes, and custom 
   waves.  A preset can have up to 4 of each.  
   
   With custom shapes, you can draw an n-sided shape (with 3-100 sides) anywhere 
   on the screen, at any angle and size, in any color, and at any opacity.  You 
   even have the option to map the previous frame's image onto the shape, which 
   makes for some incredible possibilities (such as realtime hardware fractals - 
   see the 'Geiss - Feedback' preset).  You can also write per-frame code to 
   control all of these things about the shape(s).  This way, they can react to
   the audio or change over time - whatever you can imagine.  You are limited to
   four custom shapes per preset, however, each one of those can be instanced,
   which lets you draw a huge number (up to 1024) of them each frame, if you 
   want to, and each one can be totally different (as long as the value of
   the 'instance' variable ends up influencing the other properties).
   
   With custom waves, you can draw the waveform (or the frequency spectrum)
   wherever, whenever, and however you want; a great addition since MilkDrop 
   1.03, where only the built-in waveforms were possible.  With custom waves
   you can also write per-frame code to control the waves, and per-point code
   to place every point (or line segment) on the wave exactly where you want,
   and in exactly the color you want, and so on.
   Remember those q1-q32 variables that were committed at the end of the preset
   initialization code, then reset (to those values) at the beginning of each
   frame, and then (potentially) modified in the preset per-frame code?  Those
   (potentially modified) values of q1-q32 - as they were at the end of the
   preset's per-frame code, each frame - are piped into the custom wave & custom 
   shape per-frame code.  So if you read 'q3' in the custom wave per-frame 
   code, what you're really reading is the value of 'q3' as it was left at the 
   end of this frame's per-frame code.  Again, see the q_vars.gif image 
   for a diagram of the flow of the values of the q1-q32 varibles.
   For custom waves and shapes, you can modify q1-q32, if you like, in the per-
   frame equations.  As usual, the values of the Q variables will not persist 
   from frame to frame, though - they are reset on each new frame, to match
   the values they had at the end of the *preset's* per-frame code, this frame. 
   
   For custom waves, you also have one more link in the chain: per-point
   (aka per-vertex) code.  This code is executed once for each data point in the 
   waveform.  The initial values of q1-q32 coming in (for the first point)
   are the values that stood at the end of the custom wave per-frame code,
   this frame.  If you then modify q1-q32 in the per-point code (or even if you
   don't), the values will pass on to the next point.  You could, for example, 
   smooth out a waveform using this.
   THE 'T' VARIABLES
   ----------------------
   There are 8 additional variables available for custom waves and shapes:
   t1-t8.  These are very similar to the Q variables, but they exist only
   for custom waves & shapes.  To see how the data flows from variable pool
   to variable pool for the T vars, take a look at the diagram below.  Like
   the Q variables, they exist to help you bridge some gaps between variable
   pools.  However, the T variables are a bit simpler to understand than the 
   Q's.  The diagram below should explain it all.
   
   
   


   CUSTOM SHAPE PER-FRAME VARIABLES
   ----------------------
       NAME    WRITABLE? RANGE    DESCRIPTION
       ----    --------- -----    -----------                                                                   
       num_inst   no     1-1024   The total # of instances (the number of times to repeat the per-frame equations for, & draw, this shape).
       instance   no     0..num_inst-1   The current instance number that the equations are being executed for.
       sides      yes    3-100    the default number of sides that make up the polygonal shape
       thick      yes    0/1      if ON, the border will be overdrawn 4X to make it thicker, bolder, and more visible
       additive   yes    0/1      if ON, the shape will ad