slider

Controlling the range of a set of numbers

This patch is intended to show how to generate any desired range of numbers by some combination of the following operations: 1) generate a set of possible numbers with one of the number-generating objects shown in the example "Some objects for generating numbers", 2) optionally scale the size of the range by multiplying all the numbers by a common factor, 3) optionally offset the range by adding a certain amount to each of the numbers, 4) optionally use those numbers to look up a stored set of desire

Crossfade video and audio

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).

Linear note movement

The line object interpolates linearly from its current value to some new destination value, ramping over a specified period of time, reporting its intermediate values along the way. In this example, we instruct line to ramp toward a given destination value, arriving there in 2 seconds, sending out a report of its progress (the intermediate values as it goes toward the destination) 12 times per second (i.e., once every 83.333 milliseconds).

Constant power panning using table lookup

In "Constant power panning using square root of intensity" we used the square root of the desired intensity for each speaker to calculate the amplitude of each speaker. However, square root calculations are somewhat computationally intensive, and it would be nice if we could somehow avoid having to perform two such calculations for every single audio sample. As it happens, the sum of the squares of sine and cosine functions also equals 1.

Constant power panning using square root of intensity

The intensity of sound is proportional to the square of its amplitude. So if we want to have a linear change in intensity as we go from 0 to 1 or 1 to 0, we need to use the square root of that linear change to calculate the amplitude. This example patch is exactly like "Linear amplitude panning", except that we consider the linearly changing signal from line~ to be the intensity rather than the amplitude, and we take the square root of that value to obtain the actual amplitude for each speaker.