Simple audio mixing with matrix~
This patch shows how to crossfade between two sounds. Initially, two different sound files are loaded into two different sfplay~ objects. When you click the toggle marked "start/stop", both sound files will play, but you'll only hear the one on the left because its amplitude is being multiplied by a constant signal value of 1 from the sig~ 1 object, while the one on the right is being multiplied by a signal value of 0 from the line~ object.
To jump immediately to a new location in a movie, you can send the frame message to jit.movie (or jit.qt.movie). To crossfade to a new location, instead of a jump cut, you need to be playing the video twice, and crossfade from the current video to the second video, after which you can stop playing the first video. To do that again, you can just reverse the process: start the first video at the new location, crossfade back to the first video, and stop playing the second one.
You can make a crossfade between two videos or betwen two sounds by multiplying the amplitude of one of them by values going progressively from 1 to 0 while you multiply the other by values going progressively from 0 to 1. In this example, we use a slider object that outputs values from 0 to 1 to control the volume of two movie soundtracks, using the vol attribute of jit.qt.movie (or jit.movie).
This patch is functionally identical to the mix~ abstraction in "A useful subpatch for mixing and balancing two sounds"; you can read its explanation there. It's repeated here in order to focus on the topic of initialization: setting up the initial state of your program the way you want it.
This demonstrates a linear interpolation formula for achieving a weighted balance of two signals.
Mixing or blending two things—whether it’s two sounds or two videos—just means taking a certain amount of thing A and a certain amount of thing B and adding them together.
If we want to use the delay crossfading technique shown in "Abstraction for crossfading between delay times" for multiple different delays of the same sound, the simplest solution is just to make multiple copies of that abstraction and send the same audio signal to each one. However, that's a bit inefficient in terms of memory usage because each subpatch would have its own tapin~ object, each of which would be containing the same audio data.
This patch demonstrates the use of the abstraction in "Abstraction for crossfading between delay times". It requires that you have saved that abstraction with the name delayxfade~.
This example shows my preferred method for changing between different fixed delay times. It's an abstraction that I regularly use when I want a simple delay, and want the ability to change the delay time with no clicks or pitch changes. It's designed as an abstraction so that it can be used as an object (a subpatch) within any other patch.