The patch cords that connect MSP objects look different from normal patch cords because they actually do something different. They describe the order of calculations in a signal network. The connected objects will be used to calculate a whole block of samples for the next portion of sound.
Max objects can communicate remotely, without patch cords, with the objects
send and
receive (and some similar objects such as
value and
pv). You can transmit MSP signals remotely with
send and
receive, too, but the patch cord(s) coming out of
receive will not have the yellow-and-black striped appearance of the signal network (because a
receive object doesn't know in advance what kind of message it will receive). Two MSP objects exist specifically for remote transmission of signals:
send~ and
receive~.
send and receive for Max messages; send~ and receive~ for signals
The two objects
send~ and
receive~ work very similarly to
send and
receive, but are only for use with MSP objects. Max will allow you to connect normal patch cords to
send~ and
receive~, but only signals will get passed through
send~ to the corresponding
receive~. The MSP objects
send~ and
receive~ don't transmit any Max messages besides signals.
There are a few other important differences between the Max objects
send and
receive and the MSP objects
send~ and
receive~.
• 1. The names of
send and
receive can be shortened to
s and
r; the names of
send~ and
receive~ cannot be shortened in the same way.
• 2. A Max message can be sent to a
receive object from several other objects besides
send, such as
float,
forward,
grab,
if,
int, and
message;
receive~ can receive a signal only from a
send~ object that shares the same name.
• 3. If
receive has no typed-in argument, it has an inlet for receiving
set messages to set or change its name;
receive~ also has an inlet for that purpose, but is nevertheless required to have a typed-in argument.
• 4. Changing the name of a
receive~ object with a
set message is a useful way of dynamically redirecting audio signals. Changing the name of
receive~, however, does not redirect the signal until you turn audio off and back on again.
Examples of each of these usages can be seen in the tutorial patch.
The MSP object
gate~ works very similarly to the Max object
gate. Just as
gate is used to direct messages to one of several destinations, or to shut the flow of messages off entirely,
gate~ directs a signal to different places, or shuts it off from the rest of the signal network.
In the example patch, the
gate~ objects are used to route signals to the left audio output, the right audio output, both, or neither, according to what number is received from the
umenu object.
gate~ sends a signal to a chosen location
It is worth noting that changing the chosen outlet of a
gate~ while an audio signal is playing through it can cause an audible click because the signal shifts abruptly from one outlet to another. To avoid this, you should generally design your patch in such a way that the
gate~ object's outlet will only be changed when the audio signal going through it is at zero or when audio is off. (No such precaution was taken in the tutorial patch.)
It's a fundamental physical fact that when we add together two sinusoidal waves with different frequencies we create interference between the two waves. Since they have different frequencies, they will usually not be exactly in phase with each other; so, at some times they will be sufficiently in phase that they add together constructively, but at other times they add together destructively, canceling each other out to some extent. They only arrive precisely in phase with each other at a rate equal to the difference in their frequencies. For example, a sinusoid at 1000 Hz and another at 1002 Hz come into phase exactly 2 times per second. In this case, they are sufficiently close in frequency that we don't hear them as two separate tones. Instead, we hear their recurring pattern of constructive and destructive interference as beats occurring at a sub-audio rate of 2 Hz, a rate known as the difference frequency or beat frequency. (Interestingly, we hear the two waves as a single tone with a sub-audio beat frequency of 2 Hz and an audio frequency of 1001 Hz.)
When the example patch is opened, a
loadbang object sends initial frequency values to the
cycle~ objects—1000 Hz and 1002 Hz—so we expect that these two tones sounded together will cause a beat frequency of 2 Hz. It also sends initial values to the
gate~ objects (passing through the
umenus on the way) which will direct one tone to the left audio output and one to the right audio output.
The two waves interfere at a rate of 2 Hz
• Click on
ezdac~ to turn audio on, then use the
slider marked ‘Volume’ to adjust the loudness of the sound to a comfortable level. Note that the beats occur exactly twice per second. Try changing the frequency of Oscillator B to various other numbers close to 1000, and note the effect. As the difference frequency approaches an audio rate (say, in the range of 20-30 Hz) you can no longer distinguish individual beats, and the effect becomes more of a timbral change. Increase the difference still further, and you begin to hear two distinct frequencies.
• Philosophical tangent: It can be shown mathematically and empirically that when two sinusoidal tones are added, their interference pattern recurs at a rate equal to the difference in their frequencies. This apparently explains why we hear beats; the amplitude demonstrably varies at the difference rate. However, if you listen to this patch through headphones—so that the two tones never have an opportunity to interfere mathematically, electrically, or in the air—you still hear the beats! This phenomenon, known as binaural beats is caused by ‘interference’ occurring in the nervous system. Although such interference is of a very different physical nature than the interference of sound waves in the air, we experience it as similar. An experiment like this demonstrates that our auditory system actively shapes the world we hear.
The
slider marked ‘Volume’ has been set to have a range of 101 values, from 0 to 100, which makes it easy to convert its output to a float ranging from 0 to 1 just by dividing by 100. (The decimal point in argument typed into the
/ object ensures a float division.)
A volume fader is made by converting the int output of slider to a float from 0. to 1.
The
*~ objects use the specified amplitude value to scale the audio signal before it goes to the
ezdac~. If both oscillators get sent to the same inlet of
ezdac~, their combined amplitude will be 2. Therefore, it is prudent to keep the amplitude scaling factor at or below 0.5. For that reason, the amplitude value—which the user thinks of as being between 0 and 1—is actually kept between 0 and 0.5 by the
* 0.5 object.
The amplitude is halved in case both oscillators are going to the same output channel
Because of the wide range of possible audible amplitudes, it may be more meaningful in some cases to display volume numerically in terms of the logarithmic scale of decibels (dB), rather than in terms of absolute amplitude. The decibel scale refers to relative amplitude—the amplitude of a signal relative to some reference amplitude. The formula for calculating amplitude in decibels is
dB = 20(log10(A/Aref))
where A is the amplitude being measured and Aref is a fixed reference amplitude.
The subpatch AtodB uses a reference amplitude of 1 in the formula shown above, and converts the amplitude to dB.
The contents of the subpatch AtodB
Since the amplitude received from the
slider will always be less than or equal to 1, the output of
AtodB will always be less than or equal to 0 dB. Each halving of the amplitude is approximately equal to a 6 dB reduction.
AtodB reports amplitude in dB, relative to a reference amplitude of 1
• Change the position of the
slider and compare the linear amplitude reading to the logarithmic decibel scale reading.
Most signal networks require some changing values (such as an amplitude envelope to vary the amplitude over time) and some constant values (such as a frequency value to keep an oscillator at a steady pitch). In general, one provides a constant value to an MSP object in the form of a
float message, as we have done in these examples when sending a frequency in the left inlet of a
cycle~ object.
However, there are some cases when one wants to combine both constant and changing values in the same inlet of an MSP object. Most inlets that accept either a
float or a
signal (such as the left inlet of
cycle~) do not successfully combine the two.
For example,
cycle~ ignores a
float in its left inlet if it is receiving a
signal in the same inlet.
cycle~ ignores its argument or a float input when a signal is connected to the left inlet
One way to combine a numerical Max message (an
int or a
float) with a signal is to convert the number into a steady signal with the
sig~ object. The output of
sig~ is a signal with a constant value, determined by the number received in its inlet.
sig~ converts a float to a signal so it can be combined with another signal
In the example patch, Oscillator B combines a constant frequency (supplied as a
float to
sig~) with a varying frequency offset (an additional signal value). The sum of these two signals will be the frequency of the oscillator at any given instant.
For the most part, the phase offset of an isolated audio wave doesn't have a substantial effect perceptually. For example, a sine wave in the audio range sounds exactly like a cosine wave, even though there is a theoretical phase difference of a quarter cycle. For that reason, we have not been concerned with the rightmost phase inlet of
cycle~ until now.
A sine wave offset by a quarter cycle is a cosine wave
However, there are some very useful reasons to control the phase offset of a wave. For example, by leaving the frequency of
cycle~ at 0, and continuously increasing its phase offset, you can change its instantaneous value (just as if it had a positive frequency). The phase offset of a sinusoid is usually referred to in degrees (a full cycle is 360°) or
radians (a full cycle is 2π radians). In the
cycle~ object, phase is referred to in wave cycles; so an offset of π radians is
1/
2 cycle, or 0.5. In other words, as the phase varies from 0 to 2π radians, it varies from 0 to 1 wave cycles. This way of describing the phase is handy since it allows us to use the common signal range from 0 to 1.
So, if we vary the phase offset of a stationary (0 Hz)
cycle~ continuously from 0 to 1 over the course of one second, the resulting output is a cosine wave with a frequency of 1 Hz.
The resulting output is a cosine wave with a frequency of 1 Hz
Incidentally, this shows us how the
phasor~ object got its name. It is ideally suited for continuously changing the phase of a
cycle~ object, because it progresses repeatedly from 0 to 1. If a
phasor~ is connected to the phase inlet of a 0 Hz
cycle~, the frequency of the
phasor~ will determine the rate at which the
cycle~ object's waveform is traversed, thus determining the effective frequency of the
cycle~.
The effective frequency of the 0 Hz cycle~ is equal to the rate of the phasor~
The important point demonstrated by the tutorial patch, however, is that the phase inlet can be used to read through the 512 samples of
cycle~ object's waveform at any desired rate. (In fact, the contents of
cycle~ can be scanned at will with any value in the range 0 to 1.) In this case,
line~ is used to change the phase of
cycle~ from .75 to 1.75 over the course of 10 seconds.
The result is one cycle of a sine wave. The sine wave is multiplied by a ‘depth’ factor to scale its amplitude up to 8. This sub-audio sine wave, varying slowly from 0 up to 8, down to -8 and back to 0, is added to the frequency of Oscillator B. This causes the frequency of Oscillator B to fluctuate very slowly between 1008 Hz and 992 Hz.
• Click on the
message box in the lower-left part of the window, and notice how the beat frequency varies sinusoidally over the course of 10 seconds, from 0 Hz up to 8 Hz (as the frequency of Oscillator B approaches 1008 Hz), back to 0 Hz, back up to 8 Hz (as the frequency of Oscillator B approaches 992 Hz), and back to 0 Hz.
The remaining portion of the tutorial patch exists simply to demonstrate the use of the
set message to the
receive~ object. This is another way to alter the signal flow in a network. With
set, you can change the name of the
receive~ object, which causes
receive~ to get its input from a different
send~ object (or objects).
Giving receive~ a new name changes its input
• Click on the
message box containing
set sawtooth. Both of the connected
receive~ objects now get their signal from the
phasor~ in the lower-right corner of the window. Click on the
message boxes containing
set outL and
set outR to receive the sinusoidal tones once again. Click on
ezdac~ to turn audio off.
It is possible to make signal connections without patch cords, using the MSP objects
send~ and
receive~, which are similar to the Max objects
send and
receive. The
setmessage can be used to change the name of a
receive~ object, thus switching it to receive its input from a different
send~ object (or objects). Signal flow can be routed to different destinations, or shut off entirely, using the
gate~ object, which is the MSP equivalent of the Max object
gate.
The
cycle~ object can be used not only for periodic audio waves, but also for sub-audio control functions: you can read through the waveform of a
cycle~ object at any rate you wish, by keeping its frequency at 0 Hz and changing its phase continuously from 0 to 1. The
line~ object is appropriate for changing the phase of a
cycle~ waveform in this way, and
phasor~ is also appropriate because it goes repeatedly from 0 to 1.
The
sig~ object converts a number to a constant signal; it receives a number in its inlet and sends out a signal of that value. This is useful for combining constant values with varying signals. Mixing together tones with slightly different frequencies creates interference between waves, which can create beats and other timbral effects.
See Also
Name |
Description |
gate~ |
Route a signal to one of several outlets
|
receive~ |
Signals can be received from any loaded patcher, without patch cords
|
send~ |
Transmit signals without patch cords
|
sig~ |
Constant signal of a number
|