27.11.2012 Views

programming with max/msp - Virtual Sound

programming with max/msp - Virtual Sound

programming with max/msp - Virtual Sound

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Interlude A - Programming <strong>with</strong> Max/MSP IA<br />

Fig. IA.7 Summing numbers that contain decimal points<br />

Everything that we have covered to this point about addition also applies to<br />

subtraction, multiplication, and division. Try building the patch shown in Figure<br />

IA.8 to verify that this is the case:<br />

Fig. IA.8 Other mathematical operators<br />

A brief piece of advice is in order at this point: do these exercises! Although<br />

they may seem trivial, doing them will help you to notice the details and the<br />

quirks of the Max/MSP environment, details whose importance will be revealed<br />

in the patches that we will pursue in the following chapters. For example, in<br />

the test case <strong>with</strong> the comment “floating point division and the use of the<br />

message box”, you see that we are submitting a list of integers (“10 4”) for<br />

evaluation. Despite the fact that integers are submitted, the operator was<br />

already declared to represent a floating point operation, thanks to the floating<br />

point argument provided in its object box, and as a consequence, the result<br />

emitted will be a floating point number.<br />

Let’s again use some of these simple operations in a musical context. You’ll<br />

remember how the distance between two notes, an interval, can be expressed<br />

as a ratio between the two frequencies. For example, the interval of a fifth,<br />

corresponding to 7 semitones, can be expressed using the ratio 3/2. Given a<br />

frequency (let’s say 261.63 Hz, which is middle C), if we multiply the frequency<br />

by 3 and then divide by 2, we will obtain the frequency for the note a fifth<br />

above (which in this case would turn out to be 392.44 Hz, a G). To see this in<br />

action, open the file IA_02_fifth.<strong>max</strong>pat (shown in Figure IA.9):<br />

In the patch we see that the note number generated by the kslider is<br />

transformed into frequency though the use of mtof, and is then sent to a<br />

saw~ oscillator. The output of mtof is also multiplied by 3/2, in order to obtain<br />

the frequency needed to sound the note a fifth above, which is then sent to a<br />

second saw~ oscillator. Note that the arguments to the multiplier object and<br />

from “Electronic Music and <strong>Sound</strong> Design” Vol. 1 by Alessandro Cipriani and Maurizio Giri<br />

© ConTempoNet 2010 - All rights reserved<br />

135

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!