Archive: Make 2 Pics alternate to the beat?


11th October 2002 03:07 UTC

Make 2 Pics alternate to the beat?
Does anyone know a way I can make 2 pictures alternate to the beat? ie on the first beat the first picture would show, then on beat 2 the other picture would show, 3rd beat the first picture...etc.
Thanks anyone for your help.


11th October 2002 06:00 UTC

You could probably do it with a buffer save set to alternate save/restore.


11th October 2002 20:29 UTC

:(
Well I would certainly follow your advice if I knew how. I'm kind of a n00b. (Well actually, a lot n00b.) Looking at the window for buffer save, I think it will serve my purposes; problem is I have no idea how to pull it off. :D So if someone could help me out, I'd appreciate it.


11th October 2002 20:53 UTC

OK
I did this:
Render/Picture (picture 2)
Misc/Buffer Save (buffer 2)
Render/Picture (picture 1)
Misc/Buffer Save (buffer 1)

And what this produces is a rapidly flashing amalgamation of the two pictures. Does anyone have any suggestions? All this AVS crap is so bloody confusing...


11th October 2002 20:53 UTC

First, make an effect list containing:

Render > Picture (your first picture, set to Replace)
Misc > Buffer Save (save to buffer 1, replace)
Render > Picture (your second picture, set to Replace)
Trans > Dynamic Movement:
* Grid size 1x1
* Check 'no movement, just blend'
* init: pic=0
* frame: pic=bnot(pic)
* pixel: alpha=pic
* source: buffer 1

Then turn off "Enable" in the effect list, and turn on "Enable onbeat for 1 frame". Set the effect list's input to ignore, output to replace. Leave 'clear every frame' unchecked.


How this works:
Let's take a look at the effect list. It gets executed for 1 frame whenever there is a beat.

First we render the first picture and copy it to Buffer 1 (a buffer is an extra invisible image you can use to store something you don't need immediately). Then we render the second picture over the current frame.
Then we use a 'dynamic movement' as a dynamic blend (this is its secondary function). The variable 'pic' starts out with value 0. Every active frame (in the frame code), we apply the boolean NOT operation using bnot(). This flips pic's value around (1 -> 0, 0 -> 1).
Then, we use that as the alpha value. The alpha value is a real number from 0 to 1 that specifies the transparency of the source blended with the current frame. For example, an alpha value of 0.5 would do a 50/50 blend between the two.
Because pic (which is assigned to alpha in the pixel code) alternates between 0 and 1, we switch between 'completely visible' and 'completely invisible'. We're using Buffer 1 as the source (which contains the first picture), blending with the current frame (which contains the second picture). This effectively alternates between the two pictures every time the effect list is executed.

Summary:
- Pictures are only rendered once every beat, not every frame. (fast!)
- Until the first beat, the image is black, rather than recycling whatever was in the buffer previously (good!).
- Uses one buffer.


11th October 2002 21:30 UTC

AMAZING!
Awesome, thanks a lot. It made exactly the effect I needed.
(How does anyone figure this stuff out?):igor:


12th October 2002 06:18 UTC

Lots of free time. :D


12th October 2002 22:28 UTC

Originally posted by Bob Finklestein
(How does anyone figure this stuff out?)
AVS presets are just like computer programs, AVS draws what it does by going through the preset in a fixed order and doing exactly what it is told to do in each effect. If you understand what each effect does well enough then you can convert any idea into an AVS preset. The code is the same, since its all run through in a specific order, so if you use some logic (and sometimes some tricks) you can write code that does exactly what you want it to do.