0% found this document useful (0 votes)
18 views1 page

Emsd1 001 155

This document discusses generating random numbers between a minimum and maximum value in Max. It shows a Max patch that takes the difference between the maximum and minimum values, adds 1 to get the argument for the random object, and adds the minimum value to the random number output to produce a result within the desired range. The example generates numbers between 220Hz and 1760Hz, corresponding to musical notes.

Uploaded by

jackim123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

Emsd1 001 155

This document discusses generating random numbers between a minimum and maximum value in Max. It shows a Max patch that takes the difference between the maximum and minimum values, adds 1 to get the argument for the random object, and adds the minimum value to the random number output to produce a result within the desired range. The example generates numbers between 220Hz and 1760Hz, corresponding to musical notes.

Uploaded by

jackim123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

IA2 Practice Paragraph IA.

2 - Generat ing rando m numbe rs

numbers between 0 and its argument minus 1. We have applied th is calculation


to the patch conta ined in t he fi le IA_03_random _min_max.maxpat , w hich is
seen in f igure IA 16. As you can see, we have used the previously demo nstrated
technique of sending a bang t o t he inlet of the - object everytime that its right
inlet is changed (shown originally in Secti on IA. 1) in order to always generate a
result. To t his result we then add 1 to obta in the correct argument fo r random.
At t he same t ime, the minimum value is also routed to the right inlet of a +
object, establishing t he base of th e range to be generated .
maximum

'~~-----~
1~1~0) diff erence
bang to
gene rate a +1
ra ndom {difference + 1) to be used as
number the argumen t to the random
l object
rando m minimum value to
~ be used as the
~ argum ent fo r the
+ ad dition obj ect

@] number genera ted between 220 and 1760

Fig. IA.16 The fi le IA_0 3_ random_m in_max.maxpat

Note that the right inlet of the + object is connected to a second numbe r box
show ing t he number 220 (the fi rst box is higher in t he patch). The point of this
lower number box is simply to "visually echo" the number in the up per number
box labelled "m inimum" into t he lowe r part of th e patch.2 Not ice t hat th e box
to be dupl icated, at the top right, has t hree patch cords leaving it. The fi rst cord
heads towards the button in th e uppe r left, the second goes to the "co ld "
input of the subt raction object immed iately below th e button, and th e th ird is
routed to t he "echo" number box at t he bottom right, from w hence the data
continues on to the "co ld" input of the addit ion object at th e lower left.
You should verify t hat t he patch works fo r a few minimum/maximum pairs.3
In the example show n in th e figure, t he interval used lies betwee n 220 and
1760. These two values correspond to freq uencies in hertz fo r A below middle
C and t he A three octaves higher.
The values used in th e example above sugg est that we could use th is patch to
generate random frequencies to be sent to an oscillator, and t his is exactly what
we've done in the patch shown in fig ure IA 17, w hich we invite you to construct

2 The value of the lower number box should never be mod ified "by hand"; changes must all be
made from t he upper number box. (The reason why should be evident fr om analyzing t he route
taken by the data!)
3 Make sure that t he any value that you enter for t he minimum number is less than the value of t he
maximum, or else you won't obtai n meaningfu l intervals.
140

You might also like