You are on page 1of 11

Analysis Introduction in Max/MSP

Level Display
Maz/MSP has a few tools that let you see the level of a signal. As any other level
meters the display is related to a time interval, this can be changed in the Inspector for
any of these objects (Ctrl + Click > Get Info). All the examples in this pages were
done by using a send~ object connected to these objects inputs.

number~
The number~ object displays the value of a signal coming in its inlet. The value is
expressed as the amplitude value of the signal at that specific point in time. The time
interval that the number~ object displays is related to its interval time set in its
Inspector.

meter~
The meter~ is a simple signal level meter that can be attached to any signal whose
level is between -1 and 1. Other signals should be scaled first. Each "LED" on the
meter represents a change of 3dB from the previous step, by default. The red "over"
LED comes on if the signal is greater than or equal to 1, and lasts for about a second.
Its attributes can be changed in its Inspector.
levelmeter~
The levelmeter~ object is a level meter that displays the RMS value of an incoming
signal. This meter has a ballistic controller, which means it has an attack and release
time that can be set in its Inspector. These controllers are planned to resemble the
human hearing integration times, which can be useful in displaying a value that is
closer to loudness than just the signal level.

A umenu attached to a message box containing the instruction mode$1 can be used to
switch the metering mode to some of the most conventional meters used in the past.
The contents of the umenu’s Inspector are as follows.
average~
The average~ object outputs the average value in amplitude of a signal. The time span
that will be averaged is given in samples and can be typed as an integer argument, the
default is 100. We can then connect this object to a number~ or a scope~ object to see
the value. This object also accepts the following messages: rms, absolute and bipolar.
This messages change the type of average being processed.

In this case the value displayed is the absolute value.

Signal Display
A very simple way of knowing what is happening with a sound is by using a visual
display.

scope~
The scope~ object can be used to display any kind of continuous value, including a
sound signal. The tricky part for this to display any meaningful is to change the
samples per buffer, this can be done by attaching a number box to its left inlet.
The signal above is a 100Hz triangular wave.

The scope~ object also has a xy mode. If you connect two signals to its 2 inputs you
can check if two signals are in phase.

Two 1000Hz sine wave signals in phase.

waveform~
The waveform~ object can be used to view and edit the contents of a buffer. The
problems of this object is that it needs to be related to a buffer~ object which makes
things more complex for real time analysis. The message set followed by the name of
the buffer~ object on its right inlet sets the file which will be read.

Text Outputs
There are a couple of objects in Max that let you output a signal as a series of values,
this might be useful but it would require a lot of patience to format the data.

capture~
The capture~ object can be used to store a signal as a text. An argument will specify
the number of values it will store.
In this case the capture object will store the amplitude values for 512 samples. By
double clicking on this object we can access a text file of the values. The f argument
is telling this object to capture the first values it receives and store them, if there is no
argument it will continuously dump the oldest set of values.

A typical set of values from a capture~ object.

snapshot~
The snapshot~ object can be used to get a specific value on a specific moment in time.
By clicking on a bang object connected to its right input it will output the amplitude
value of a signal.

Hilbert Transform

hilbert~
The hilbert~ object performs a Hilbert transform to a signal. The output of this is two
signals 90o out of phase with each other. These values are the instantaneous amplitude
and frequency of a signal. If we connect this object to a scope~ object we can see the
display of these two values.
Hilbert transform of a 1000Hz sine wave.

Frequency Analysis
Max/MSP has a few frequency analysis display objects and also some FFT objects,
some work better than others. In this tutorial we will have a look at the most basic
ones.

spectroscope~
The spectroscope~ object is used to display the spectral content of a signal. It has two
modes: the spectrogram mode and the sonogram mode. Both modes display frequency
content in different ways. The Inspector is once again used to change this objects
settings. In the Inspector you can change the range of frequencies being shown, the
interval being measured, the scale, etc.

spectroscope~ object in spectrogram mode.


spectroscope~ object in sonogram mode.

fft in Max/MSP
Max/MSP have a few objects that perform fft process. The most simple of this objects
is the fft~ object, these object outputs a set of values which corresponds to the number
of fft bins specified by an argument typed into the object.

In the next patch we can see a fft~ object connected to a capture~ object which will
capture the first set of values corresponding to each bin of the fft. The object is also
connected to a cartopol~ object which transforms the signal into amplitude and phase.
If we connect the amplitude output to a scope~ object which shows the whole
spectrum from 0 Hz to the sampling frequency.

Cepstrum
The cepstrum is the Fourier transform of the log of a Fourier transform. This can be
used to show the main spectral qualities of a signal. The next patch takes the output of
a the amplitude of a fft changes its value to logarithmic values and then performs a fft.
Cepstrum of a 1000Hz saw tooth wave, these shows the more prominent harmonics.

Multi Band Real Time Frequency Analyzer

The fft~ object in Max/MSP is not the only object that performs fft operations. The
pfft~ object is used to encapsulate another patch where fft processing is done. pfft~,
like poly~ and a few other objects, is actually an "encapsulating" object. This means
that the object itself cannot accomplish a specific task; rather, it depends on a user-
written patcher to describe the function of the object. This object also adds some
functions (e.g. windowing) and lets you use a patch you might be using constantly
inside another patch.

Therefore we need to create the patch that will be inside the pfft~ object. The patch
looks as follows:
Any patcher that will be used within pfft~ needs to have some way to tell pfft~ how
many inputs and outputs will be required. fftin~ and fftout~ objects control the audio
inputs and outputs, while standard in objects control parameters that will be used with
the patcher.

First, you should understand the output of the fftin~ object. The left-most outlet is
the "real" output of the FFT, while the middle output is the "imaginary" output of the
FFT calculation. This can be thought as amplitude and phase The right-most output,
however, is very important. It tells us which "bin" we are currently seeing from the
fftin~ outlets. The amplitude and phase will correspond to this current “bin” which in
more simple words is the frequency being analyzed.
The fftin~ takes incoming audio, and does a number of calculations on the sample
data. The output is also an audio signal, but it contains calculated level and phase
information for each frequency that you are testing. Each of these bins is called a
"bin", and the number of bins is based on the "framesize" that you feed to pfft~. Since
Max/MSP can only provide data at either message or audio speed, a compromise had
to be made. The decision was to output the frequency bin measurements as audio
data, with an extra signal telling you which bin you are currently receiving.
That extra signal is the key to determining what frequency is measured in each
calculation. To do this, we need to take a few bits of information into consideration -
sample rate and frame size. The upper right part of the patcher does this.

We take the sample rate from the dspstate~ output as a starting point for calculating
the current frequency. The output is used to bang fftinfo~ for the actual framesize.
Dividing the sample rate by the framesize will give us the size of frequency bins (in
Hz). Now, we multiply the output of the right-most outlet of fftin~ by this number to
get the current bin's frequency in Hz. This is the basis of the logic we are about to
examine.

We take this frequency and feed it to some logical operands. What this does is
compare the value to see if it is below the first cut off point, between the two cutoff
points or above the second cut off point. The in objects are used to change the values
of the logical operands. Remember the output of these logical objects is 1 if the
condition is met or 0 if not.

This results are then multiplied by 1, 2 or 3 to open the specific output of a gate~
object. Finally, we add 0.1 to the figure, just in case the actual floating point result is
one of those "just under" values (like if 2.0 is really 1.9999999 in memory). This is
just an extra caution point to make sure gate~ gets the right value.

Now, using this logical calculation, we set the gate to open only one outlet, and send
the original bin calculations to the fftout~ outputs. Since fftout~ reverses the
calculation of fftin~, what we are doing is to split the signal into three audio streams:
one that is low frequency, one that is mid-frequency and one that is high frequency.
So, all of this was really to accomplish the equivalent of a crossover circuit - it turns
one full-frequency audio stream into three frequency-specific audio streams.

Now we can make the interface that will display the values. It may look like this:
There are a few simple setup bits. First, we use a checkbox connected to an adc~
object to start analysis. We also have a signal fader object (and level meter) to trim
the input (in case it's overly loud). The output of the trim control is fed to pfft~. The
arguments for this object are: first the name of the patch that it will be reading; and
second, the number of frequency bins that it will use. The three outputs of this object
feed three level meters - which will give us the volume levels of the three frequency
segments we've defined.

In order to complete the functionality, we need to add some user settings. First, the
low and high breakpoint frequencies are entered (using number boxes), and fed to the
pfft~ to control its calculations. The reporting interval (how often the meters are
changed) is also set (in milliseconds). This simply feeds an "interval" message and is
sent to all three meters. This interval is the time it takes for the meter to change from
one value to the next.

By expanding the logic of the frequency analyzer patcher, you can easily create a 6-,
12- or 512-band RTA.

You might also like