# scope~

## Cycle~ phase demo

This patch allows you to see how the phase relationship between two sine waves will affect the shape of the waveform when the two are mixed together. Initially, it shows a 4-Hz sinusoid and an 8-Hz sinusoid that are one-half cycle out of phase with each other. If you change the phase offset of one of the oscillators, you can see that the waves interfere differently, thus changing the shape of the waveform. However, as listeners we're not very sensitive to such changes in phase relationships, except in certain cases where waves cancel each other in extreme ways.

## Phase cancellation due to delay

A sinusoid added to a delayed version of itself will result in a sinusoid of the same frequency but with its amplitude altered. The amount of amplitude change will depend on the phase relationship between the original sinusoid and its delayed copy. The two sinusoids will interfere with each other either constructively (reinforcing each other) or destructively (tending to cancel each other).

## Interference between sound waves

When sound waves are mixed together, be it mathematically within the computer or physically in the air, they “interfere” with each other.

## Phase cancellation

When two sinusoidal waves have the same frequency, amplitude, and phase, they constructively interfere; the amplitude of their sum is twice the amplitude of each one alone. When they are exactly one half cycle out of phase, however, they completely interfere, and cancel each other out entirely; one always is positive when the other is negative, so their sum is always zero. When their phase relationship is somewhere in between those two extremes, the frequency of the sum will stay the same, but the amplitude and phase will change.

## The phasor~ object

The phasor~ object is one of the most valuable MSP signals to use as a control signal. (You wouldn't generally want to listen to it directly as audio because it's an ideal sawtooth wave and has energy at so many harmonics that it can easily create aliasing. If you want a sawtooth wave sound, it's better to use the saw~ object, which limits its harmonics so as not to exceed the Nyquist frequency.) The phasor~ outputs a signal that ramps cyclically from 0 to 1.

## Using phasor~ directly as a control signal

If you need a linear signal that repeats at a specific rate, phasor~ can be scaled and offset to provide a repeating line from one signal value to another. In this example, we use phasor~ to directly control both frequency and amplitude of an oscillator.

## Repeatedly reading a function with phasor~

The real value of phasor~ is that it provides a very accurate way to read through (or mathematically calculate) some nonlinear shape to use as a control signal (or even as an audio signal). Among other things, it might be used to create a "window" shape that can serve as an amplitude envelope for a sound. This patch demonstrates five different ways to create window or waveform shapes with phasor~. We'll discuss them (in good Max fashion) from right to left.

## Generate a sinusoid with gen~

Max provides an object called gen~ that opens up a new patching window in which you can program audio at the sample level. You build an audio network inside the gen~ window with objects that are quite similar to MSP objects, but within the gen~ window there is only audio, no non-audio events.

## Line segment control functions

In some other examples (e.g., Linear fade-in/out of audio from a different course website) you can see how the line~ object interpolates sample-by-sample in a straight line from one value to another. You provide it with a pair of numbers­­––a destination value to go to, and an amount of time in which to get there––and it changes gradually (linearly) to that destination value in that amount of time.

## Windowing an audio signal

In signal processing, a "window" is a function (shape) that is nonzero for some period of time, and zero before and after that period. When multiplied by another signal, it produces an output of 0 except during the nonzero portion of the window, when it exposes the other signal. The simplest example is a rectangular window, which is 0, then briefly is 1, then reverts to 0. The windowed signal will be audible only when it is being multiplied by 1––i.e., during the time when the rectangular windowing occurs.