Now let's see another way to control the
frequency. Get two number box, one integer and the other
the palette and put on the patcher window. Connect with a cycle~
connect the cycle~ with a dac~.
Note that I don't write a frequency value on the cycle~. This
that the cycle~ will start using its default frequency that is
don't play until a valid frequency value is received from the
Add the usual start and stop messages to the dac~ as in figure
to play mode.
In play mode, click on the integer number box and drag the mouse
high. You'll see the value in the box rapidly changing. When the
will reach an audible frequency (e.g. 20-30, but could be more,
depending on the quality of your speakers; remember that the
computer speakers often don't work at all under 100 Hz), you
to hear a glissato moving from low to high frequencies.
Now, you see, the number box don't act as button, like messages.
works as a slider that you can control dragging the mouse up and
Now try the floating point number. This one works as the former,
little difference: if you click on the left part of the box
little triangle) only the integer part of the number change; if
click on the right, the fractional part also change. So clicking
left you have a coarse control and clicking on the left you get
You can also change the box dimension to be sure to see all the
in edit mode, move the mouse near the lower right corner of the
until the cursor become a cross, then click and drag.
it is very
that you are always aware of the
patch data flow.
You must be able to figure in your mind how and when
the data flow in a Max/MSP patch.
It could be a little difficult for beginners, but only by this
the more complex patches.
So let's stop just a moment to understand exactly what's
- When the number changes (and only when the number
a message start from the number box, runs through the wire
the cycle~. This number is not a frequency, it's a
Its only meaning are its value and its format (integer or
- The cycle~ receive this number in its left inlet and uses
frequency value only because on the left inlet a frequency
expected. If you connect the number box to the
you'll hear no frequency change because on the right inlet a
value (not frequency) is expected.
- So it's the cycle~ that gives the number a meaning,
depending on the inlet the number reach. Note that the
mind about the number format because a frequency can be
way (with or without fractional part), but, with other
right format also is requested by some inlet. On the
number 50 is different from the number 50.0 so the right
the wrong format could be seen as an error.
The Floating Inspector
As you see, while dragging on a number box, you can go up and
no limits. You can also output negative numbers. Of course,
minimum and maximum to some meaningful value should be better.
To do so, go to edit mode, select the number object and click
Windows → Show Floating Inspector.
This dialog allows you to set many options for the current
object. Note that the floating inspector options are not the
all objects, because any object has its own distinctive
objects have no floating inspector at all.
For number box, integer or floating, the most important feature
range. Here you can set minimum and maximum values.
Now we are using this number to control a frequency, so set the
to reasonable values in Hertz e.g. min 20-30, max 4000-5000 (the
note on the piano is 27.5 Hz, the higher is 4186 Hz). Be sure
Min” and “No Max” check boxes are unchecked. Now you can freely
By the floating inspector you can also set the colors of the
object, the display format and a bunch of options:
- Bold: display the value in bold
- Draw Triangle: display/hide the little triangle on the
the number box
- Output Only on Mouse-Up: this is an important option (try
you check it, you'll hear no glissato while changing the
value with the
mouse. The value will change only when you leave the mouse
means that, while playing, you can change a number with no
effect until you reach the right value.
- Can't Change: make the number box read only. Useful when
used only to show a number (r.g. the result of a
- Transparent: hide the box displaying the number only.
The cycle~ has no amplitude control in itself. It always output
wave at the maximum amplitude value.
To control the sound amplitude we must insert an amplifier
signal generator (the cycle~ in our example) and the dac~.
To understand how an amplifier works on a digital signal,
a digital sound wave is a stream of number running at SR speed
44100 numbers per second). Each number is an amplitude sample
the sound wave. So the wave in this figure
is in fact a stream of numbers like this one
0 72 144 215 285 352 417 479 538
593 644 690 732 769 801 828 849 865
875 880 879 873 862 846 825 799 769 736 699 659 616 571 524
476 426 377
327 278 229 182 136 92 51 12 -23 -56 -85 -111 -133 -151 -165
-184 -184 -179 -171 -161 -147 -131 -113 -92 -71 -48 -24 0 24
48 71 92
113 131 147 161 171 179 184 184 182 175 165 151 133 111 85
56 23 -12
-51 -92 -136 -182 -229 -278 -327 -377 -426 -476 -524 -571
-699 -736 -769 -799 -825 -846 -862 -873 -879 -880 -875 -865
-801 -769 -732 -690 -644 -593 -538 -479 -417 -352 -285 -215
-144 -72 0
72 144 215 285 352 417 479 538 593 644 690 732 769 801 828
849 865 875
880 879 873 862 846 825 799 769 736 699 659 616 571 524 476
426 377 327
278 229 182 136 92 51 12 -23 -56 -85 -111 -133 -151 -165
-175 -182 -184
-184 -179 -171 -161 -147 -131 -113 -92 -71 -48 -24 0 24 48
71 92 113
131 147 161 171 179 184 184 182 175 165 151 133 111 85 56 23
-92 -136 -182 -229 -278 -327 -377 -426 -476 -524 -571 -616
-736 -769 -799 -825 -846 -862 -873 -879 -880 -875 -865 -849
-769 -732 -690 -644 -593 -538 -479 -417 -352 -285 -215 -144
-72 0 72
144 215 285 352 417 479 538 593 644 690 732 769 801 828 849
865 875 880
879 873 862 846 825 799 769 736 699 659 616 571 524 476 426
377 327 278
where each number represent the amplitude of the wave at a
like a graph with the time on x-axis and the
So, to change the wave's amplitude we can simply multiply each
for a given value. If that value is greater that 1, the
increase. If it is lower that 1, the amplitude decrease. In the
following image, a plotted digital wave (red) is multiplied by
(blue) and by 0.5
(yellow). Here is the result. You can clearly see that only
control to a signal
To apply amplitude control to a signal we only need a multiplier
between the signal generator(s) and the dac~ (see patch on the
Be sure to pick the MSP multiplier (with tilde: *~) from the MSP
Operators group, not the Max multiplier (with no tilde).
To set the amplitude value we can use a floating point number.
must set the range of the amplitude control.
In MSP, the maximum amplitude a dac~ can handle is 1, that is,
reaching the dac~, a wave must run between ±1 to avoid clipping
distortion. Of course a zero amplitude is no signal.
The cycle~ generator already output a wave at maximum amplitude,
amplifier is in fact a damper and will have the range 0 - 1
reason we must use a floating point number).
If the amplitude control would reach a value greater that 1, a
with range > ±1 would reach the dac~ and be clipped: you
no amplitude increment, but harmonic distortion (try a value
Measuring the amplitude of an incoming signal could be very
when you work with external signals. Now we'll see different
ways to do
it using standard Max/MSP objects.
To make it simple, we'll apply the measurement to the cycle~
for now. Look at the the patch 03.
Here you can see and try different ways to evaluate a signal's
|This is not a real
Here we convert the given amplitude value to dB for
only and see if the real evaluations match.
By the way, here you can find the atodb object that
convert a number to
deciBels. It is taken from the Max "Math" section on the
The atodb output is connected to a number object to show
dB. The number object is made read-only (check the
option in the
|Here is the first real
You can find the peakamp~ object on the "MSP Analysis"
object accept a signal in its left inlet and output the
absolute amplitude every k milliseconds, where k is the
in figure). You can also control the k value sending an
to the right inlet.
The peakamp~ object is very accurate and it's a good and
simple way to
evaluate the peak amplitude of a signal.
|In the palette you can
graphic objects to evaluate and show a signal amplitude.
|The peak level meter
signal in its left inlet and display the amplitude by
the usual led
line. It also output the evaluated absolute amplitude.
The object appearance can be fully edited using the
Running the patch you'll see that when the input signal
has a low
frequency (set the frequency control to 50 Hz or lower)
the result is
rapidly changing. This is not a bug. It does not happens
sounds. Here it happens because:
This object's MSP name is meter~. If you to know more
about it search
for meter~ on the MSP Reference manual.
- The peak level meter has a little buffer. When the
frequency is low it see only a section of the wave
cycle, but, more
- Here we supply a single sine wave without
nature the signals have harmonics whose frequencies
are higher than the
fundamental, so the wave is more complex and the
peak amplitude can be
evaluated also with a little buffer.
|This level meter seems
previous one, with needle in place of leds, but it has
It is not a peak level meter. It computes the RMS
the signal's amplitude. This is very important because
the peak value
is meaningful with a simple harmonic wave, but it makes
little sense to
talk about a peak
amplitude when describing a complex sound (e.g. a drum
stroke) or a
noise. This is because there are many peak
amplitudes and any one is not representative of the
So, how should we measure the amplitude of a complex
signal? We can't
take the average of the instantaneous amplitudes since
values always cancel yielding an average value of zero.
this we square each amplitude making all values
positive. We then take
square root of the average of the squared values to get
back to an
measure. The resultant measure is referred to as the
amplitude. The RMS amplitude is a more commonly accepted
because it applies to periodic sounds like sinusoids as
well as to
This object output the RMS amplitude value in dB, so
there is no need
of the atodb object.
This object's MSP name is levelmeter~. If you to know
more about it
search for levelmeter~ on the MSP Reference manual.
Now that you know more about the amplitude, you can set 0 dB on
If you connect Max/MSP to a professional mixer with measurement
input and output, you can easily set the 0 dB. On the computer,
test frequency (about 1000 Hz). Then set the
board output to the maximum (or the level you normally use, but
board should work well at the maximum with no distortion). Then
amplitude control of the patch to the maximum (i.e. 1.0). This
MSP 0 dB (you should see 0 dB on all the meters).
On the mixer, set the input slider to 0 dB and turn the input
sensitivity control (if any) until the input signal level show 0
the same for the mixer output.
Why the dac~ maximum amplitude is 1?
It's a good question. Why 1 and not 100 or 1000 or a power of 2,
1024 or the real amplitude of the sound board? Is there some
reason to set the range to 0 - 1? The answer lead us to the
computer arithmetic, so it could be a little complex business.
notes are for more
advanced (or curious) users.
- Max/MSP must work with many different sound
boards and the sound boards currently on the market can have
dac types, typically 16 or 24 bit. Maximum values are 32767
for 16 bit
(2(16-1) - 1)
and 8388607 for 24 bit (2(24-1) - 1).
But the software can't work with absolute amplitude values
because the patches you make, must work with all the sound
if you change machine or the board itself. So a conventional
amplitude value has to be set. When sending sound data to
board all values will be scaled according to the maximum
- MSP works with 32 bit floating point
numbers. This is a very accurate way to make calculations on
because 32 bit floating point numbers can hold until 18
the decimal point.
Floating point is more accurate than 24 or 32 bit integer
often think that every operations on digital signals are
with integer arithmetic it's not really true. A very
example: suppose you are working with 24 bit integer
arithmetic on a
digital wave with amplitude 8388607 (the maximum). Now
suppose you are
mixing, and this signal's amplitude is lowered multiplying
by, say, a
0.731 factor. The resulting amplitude is 6132071.717. OK:
where do you
think this 0.717 goes? It get lost because this is integer
and by this way every multiply you make creates a very
An experienced digital user can argue that with integer
never multiply by floating point numbers. You multiply by an
number creating a double precision result that will be
simple precision, but it's the same because here are the
that get lost.
The meaning of the story is: always try to work with 32 bit
point when making computations on digital signals. You can't
final rounding error, when data are sent to the board's dac
written on audio CD in the usual format (44100, 16 bit,
stereo), but at
least you save the accumulation of little sampling errors.
debate is about 48 bit integer versus 32 bit floating
James A. Moorer's paper), but under the 48 bit integer
32 bit float is surely better.
- But why 0 - 1? Even with floating point arithmetic, a
conventional amplitude of, say, 1000 could be easiest to
Because of the problem of floating point arithmetic: while
increase, you lose precision after the decimal point. This
business on real world. If someone owes you $10.95 all the
significant, but if someone owes you $100000.95 you could
discount and save the $0.95.
So, to hold the maximum accuracy, MSP choose to work with
A useful patch: Hear the Fletcher/Munson Effect
to hear the Fletcher/Munson effect you
with hi-fi speakers. This is because this effect is evident at
frequencies (under 100 Hz) and the little computer speakers are
effective at this frequencies. You can use haedphones but be
Never turn on a patch without controlling its loudness or the
your equipment. Set amplitude/loudness to 0, turn on the patch
raise the volume.
Let's do this trial.
- Return to patch 02 (single cycle~ with frequency and
- Set the frequency at (about) 1000 Hz.
- Be sure to
turn off the loudness control of your amplifier (if any) and
equalizer (if any; remember that many mixers have filters).
frequency response of your equipment must be flat
(as much as
- Set the amplitude control to 0 (no sound).
- Turn on the patch and set a suitable amplitude (not
Now begins to lower the frequency (click on the left part of the
control box to change the integer part only, going down faster).
change the amplitude. Move down the frequency only.
Under 500 Hz, the loudness will be a little lower. About and
Hz the loudness will be very low. Very low frequencies (60 Hz
lower) will be barely audible even if the amplitude is the
Why? It's your speakers? Maybe, but the real answer is that the
ear frequency response (or better, the ear\brain combination
the same for whole audible area. The ear works better
approximately from 500 to 5000 Hz. Outside this area it needs
amplitude to hear equal loudness.
This effect has been first studied
in 1937 by Fletcher
Munson who traced the human ear response curves. In 1956
& Dadson refined the Fletcher/Munson curves and today the
Robinson/Dadson curves are generally preferred over the
curves owing to their more reliable measurement results. The
International Standards Organization agreed and adapted the
Robinson/Dadson curves as the basis for ISO 226:1987; Normal
Level Contours (ELLC) (see image on the left; the MAF line is
Minimum Audible Field).
This chart say that humans don't hear all frequencies at the
same level. That is, our ears are more sensitive to some
and less sensitive to other frequencies. Not only that, but the
sensitivity changes with the sound pressure level (SPL), too.
look at the chart. You'll notice it's marked horizontally with a
denoting the frequency of sound. Vertically it's marked in SPL.
chart are a number of curved lines, each with a number (loudness
Let's begin by looking at the lowest solid line marked with a
level of 10 phons. (The loudness level in phons is a subjective
sensation--this is the level we perceive the sound to be at.)
about 500Hz to roughly 1,500Hz the line is flat on the 10dB
means that for us to perceive the sound being a loudness level
10 phons, (the overall curved line), frequencies from 500Hz to
must be 10dB. Make sense so far? OK, now look further into the
frequencies, say 5,000Hz. Notice the line dips here--this says
perceive 5,000Hz to be 10 phons when the source is actually only
To perceive 10,000Hz at the same level (10 phons), it would need
about 20dB. From this we can clearly see the ear is more
the 2,000Hz to 5,000Hz range, yet not nearly as sensitive in the
6,000Hz and up range.
Lets take a look down at the lower frequencies now, say 100Hz.
to perceive 100Hz as loud as we do 1,000Hz (when the source is
10dB), the 100Hz source must be at 30dB–that's 20dB higher than
1,000Hz signal! Looking even farther down, a 20Hz signal must be
75dB (65dB higher than the 1,000Hz signal)! We can clearly see
are not very sensitive to the lower frequencies, even more so at
Why is this? A simply physical explanation is that resonance in
ear-canal amplifies frequencies between 1500 Hz and 5000
Hz with a peak around 3000 Hz. In addition, the response in the
between 500 and 1500 is flat. All other frequencies are damped.
that the main communication
area lies in the range 500 - 5000. In this range we find human
animal voices and in the upper part of this range we find the
Now you know why the double-bass sound box is so big. Looking at
musical instruments construction, we can see many ways to
the Fletcher/Munson effect. For instance, the mechanical device
piano lower keys is adjusted to struck the string a little
respect to medium and high registers. So the player can achieve
the same loudness using the same force.
OK. We heard the Fletcher/Munson effect and we also know what is
why it happens. But now we can also measure it. Load the
Here you can see two versions of the Fletcher patch. Now look at
simplest and not hidden (left). There is a reference frequency
1000 Hz on right channel and a second cycle~ that can be set to
frequencies (8ve distance) on the left channel.
To measure the Fletcher/Munson effect you must choose a
the left, then move the amplitude control of the 1000 Hz (up on
right), until you hear the two frequencies have equal loudness.
you read the amplitude difference in dB in the read-only number
down on the right.
The atodb object convert the amplitude from absolute value to dB
This value is negative because it say how much the 1000 Hz must
damped to hear equal loudness.
The second patch version is the same with a more pleasant user
interface, but two main differences:
- it uses a slider as amplitude control: note that the
is 0-100 (set by the floating inspector); then is multiplied
by 0.01 to
achieve the 0-1 range. This is because the slider object
floating point numbers (integers only). This kind of number
common on Max. We'll see more on the next lesson.
- the converted dB value is multiplied by -1 to see a