programming with max/msp - Virtual Sound
programming with max/msp - Virtual Sound
programming with max/msp - Virtual Sound
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Interlude B - Additional elements of <strong>programming</strong> <strong>with</strong> Max/MSP<br />
There are two arguments associated <strong>with</strong> makenote, a velocity and a duration<br />
in milliseconds. In the patch, we have set velocity equal to 1 (a placeholder,<br />
as we will see), and duration equal to 500 milliseconds (or half a second).<br />
When the object receives a note-on, it will send the pitch and velocity of the<br />
note-on directly to its outlets, where, after the prescribed duration (500 milliseconds<br />
in this example) a note-off is also sent. Note that the velocity sent<br />
by the kslider (which in the example shown in the figure is a value of 103)<br />
overrides the value of 1 that had been provided as an argument. This first<br />
argument is only a placeholder that allows us to write a second argument, the<br />
note duration, after it. The second argument can also be modified by sending<br />
a value to the right inlet, which will replace the value originally specified in<br />
the second argument.<br />
Try playing some notes and changing the duration: observe how velocity values<br />
first reflect the value generated by kslider, and then, after the time specified<br />
by the duration parameter, they change to 0.<br />
Now add an addition object to the lower part of the patch as shown in Figure IB.3:<br />
Fig. IB.3 Transposing MIDI notes<br />
This patch is similar to the one in the file IA_01_transposition.<strong>max</strong>pat, which we<br />
examined in the first section of Interlude A. In this case, every key pressed on<br />
the keyboard generates two notes simultaneously, separated by a distance of<br />
7 semitones: the interval of a fifth. Every time that a kslider key is pressed,<br />
in fact, the value of the MIDI note number is sent to the makenote object and<br />
also to the addition object that adds 7 to the first note number and then sends<br />
its output to makenote. To create these note pairs, we didn’t need to repeat<br />
velocity and duration values, since these values are sent to “cold” inlets of the<br />
makenote object, which are stored as internal variables (the contents of internal<br />
variables are re-used every time that a new value arrives at the “hot” inlet). In<br />
the figure, for example, both notes (the middle C and the G above it) will have a<br />
velocity of 112 and a duration of 500 milliseconds.<br />
from “Electronic Music and <strong>Sound</strong> Design” Vol. 1 by Alessandro Cipriani and Maurizio Giri<br />
© ConTempoNet 2010 - All rights reserved<br />
IB<br />
425