Tutorial 8: Simple Mixing
This tutorial shows how to combine and fade between two images using the jit.xfade object.
Mixing Two Video Sources
One of the most common and useful things to do with video is to mix two images together.
The simplest form of video mixing is achieved by just adding the two images together, with the intensity of each of the two images adjusted in whatever proportion you desire. By fading one image up in intensity while fading the other down, you can create a smooth crossfade from one image to the other.
Jitter provides an object that accomplishes mixing and crossfading for you, called jit.xfade.
jit.xfade
The jit.xfade object takes a matrix in each of its two inlets, scales the values of each matrix by a certain amount, adds the two matrices together, and sends out a matrix that contains the resulting mix. The scaling factor for each of the two input matrices is determined by the object's attribute. The value is a single ( ) number between 1 and 0. That value determines the scaling factor for the matrix coming in the right inlet. The matrix coming in the left inlet is scaled by a factor of 1-xfade. So, if you gradually increase the value from 0 to 1, the output matrix will crossfade from the left input to the right input.
Automated Crossfade
A crossfade is one of the most common ways of making a transition from one image to another. It might be very gradual—over the course of several seconds—or it might be quite rapid, lasting a fraction of a second, to make a sudden transition that is slightly smoother than a jump cut.
In the upper left portion of the patch, we've made an automated fader from video A to video B (or vice versa). The crossfade can take any amount of time; you can specify the transition time with the number box.
The Go To switch is actually a small slider with a range of 2 and a multiplier of 100, so the only two values it can send out are and . Clicking on the right side of the switch sends out the value , the pack object sends out the message , and the line object sends out continuous values from 0 to 100 (one new value every 50 ms) over the course of five seconds. Those values are then multiplied by 0.01 to give a smoothly changing value from 0 to 1.
Summary
Adding two matrices together is the simplest way to do A-B mixing of video images. To achieve the desired balance of the two images, you first scale each matrix by some factor. You can crossfade from one image to another by decreasing the scaling factor of one image from 1 to 0 as you increase the scaling factor of the other image from 0 to 1.
The jit.xfade object makes it easy to mix and/or crossfade two matrices. Its attribute determines the balance between the two matrices. Changing the value continuously from to performs a smooth A-B crossfade. You can use line or any other Max timing object to automate crossfades.
See Also
Name | Description |
---|---|
Working with Video in Jitter | Working with Video in Jitter |
Video and Graphics Tutorial 10: Composing the Screen | Video and Graphics 10: Composing the Screen |
jit.xfade | Crossfade between 2 matrices |
line | Generate timed ramp |
pack | Create a list |
prepend | Add a message in front of input |
slider | Move a slider to output values |