Namespaces

Variants
Actions

random

From Cycling '74 Wiki
(Difference between revisions)
Jump to: navigation, search
(Initial upsert from MAXobjectNT list)
Line 2: Line 2:
  
 
==Using the {{maxword|name=random}} object==
 
==Using the {{maxword|name=random}} object==
 +
The random object generates a random value from 0 to 1 less than the value specified by the argument.
  
 
=={{maxword|name=random}} Tutorials==
 
=={{maxword|name=random}} Tutorials==
 +
The random object shows up in many tutorials and example patches. The following tutorials represent particularly useful techniques for using the object.
 +
 +
*It is introduced in [http://cycling74.com/docs/max6/dynamic/c74_docs.html#basicchapter10 Max Basic Tutorial 10: Random Drawing].
 +
*[http://cycling74.com/docs/max6/dynamic/c74_docs.html#basicchapter17 Max Basic Tutorial 17: Data Structures And Probability] uses random with {{maxword|name=uzi}} to rapidly generate values to fill up {{maxword|name=table}} and {{maxword|name=histo}} objects.
 +
*[http://cycling74.com/docs/max6/dynamic/c74_docs.html#basicchapter19 Max Basic Tutorial 19: Timing] demonstrates another common use of random, combining it with the {{maxword|name=select}} object to randomly choose between 4 constant values.
 +
*[http://cycling74.com/docs/max6/dynamic/c74_docs.html#basicchapter22 Max Basic Tutorial 22: Designing Equations] uses random in conjunction with the {{maxword|name=scale}} object to generate coefficients for use in generating equations for random drawing to an {{maxword|name=lcd}}.
 +
 +
All of the CyclistMusic patches use random in multiple places within the patches. These are a great way to get a sense of how to use the object in general and more specifically, how to incorporate randomization into timing, note selection, and other musical vocabularies.
 +
*./examples/sequencing-looping/CyclistMusic
 +
  
 
=={{maxword|name=random}} Tips and Workarounds==
 
=={{maxword|name=random}} Tips and Workarounds==
 +
The output of random is always an integer and always outputs values from 0 to 1 less than the range specified by the argument. In many cases you will want to convert these values to floating point or to offset them in some way, whether it is to control vizzie objects, OpenGL parameters or coordinates, to generate negative values, or even just to start from 1 instead of 0. In many cases you can do this by simply re-scaling the values using a scale object or by adding an offset with the {{maxword|name=+}} object.
 +
 +
<maxpat>
 +
<pre><code>
 +
----------begin_max5_patcher----------
 +
937.3oc0XszbSCCD9b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h+z2dzaFN4GyUZYqpnW2g21Ev8VRISaukn+aocvdRNZOWyKKYhCGEnjqc
 +
SG3gXzC5yFJZ1L.zrd1PCIa.vwdM+YCOaGBdRmO7jN.7DimM7fGBdvqehgmY
 +
jeFRxNd9hmsswG.dHyGdHCM9AOO3AOD7DOR9Iz5f1zbCSo6dmdnXan9Io5t9
 +
6Haysvi9lXHE6Fd+98eZBDUY6XZrsKaUgVW2t0cyMqd99xe.ck2UHA
 +
-----------end_max5_patcher-----------
 +
</code></pre>
 +
</maxpat>
 +
 +
This patch shows a simple way to use the random object to create an adaptive probability system. Similar to the functionality of {{maxword|name=decide}}, it chooses between two possible states, however, each time one state is selected it is more likely to be selected again.
 +
<maxpat>
 +
<pre><code>
 +
----------begin_max5_patcher----------
 +
1312.3ocyZssbiiBD8YmuBVUUdZc7xMIj12luislZJcg3vr51JgylrSM+6qD
 +
Hk3jwIBSPD+hko0EN8gltaZ3GWsIHq4Ade.3OA+EXyleb0lMJQiB1L0dSPU5
 +
C4ko8pGKHuophWKC1pumj+fTIOs9QonhCRA420Hx4.QOnJsfuEHjp+2zwAkh
 +
+lW9HP1.x3p6BR2mJp2M+0JE077lC0pOIdR3sM0xdw+wGkgv6fyh61mMJB9j
 +
j1TY9ch58eqimK05DMb3t.RTx3ELIR0hrCB95z6TenRTWxkJkC8rvlCxYovi
 +
vQcZkBGAeoSjVNCaQgRVS12uIANKrsi2OPToRQS8QHJBy1wB2BBgJLAm9A70
 +
w25mWc03OaMbrnl+uC84uLTzAZ6ZxBde56DjEgLda.hxFuPoJNC9VjE7jj0L
 +
EpEIerkq+1AAO8ULhGiYAtjP5D6uSd9LBEorevgpKTxmJiD6TFojeqEDBQc6
 +
YBgv9TIjDGRH8VNmINVQAlMkwA9WhibpRa47B7jlNo1j0WsCcpZamwOJhbjV
 +
ujwuKzZpMZ8aEgNI45.GDRcJJAAR2MDFiDt9r.YgPpLlBQQIv0Jh5PG2xqK.
 +
8bo0gUwDjJ5JDZCi4LmlnEIS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1A0etmwTSwieLevjKL7Xh0i+7FZRvTT3kUR8XxkUR8X+kDMxvbnsAM5Jvj1
 +
1dOuqe5Sp.RPU52a5FaFsU0TTqapp4SPG+dw7yqJQZPZW9cBIOWdnSWQuGTm
 +
y9g94mW8+yOzE3B
 +
-----------end_max5_patcher-----------
 +
</code></pre>
 +
</maxpat>
 +
 +
This may seem obvious, but when converting the output of random to floats, you can use large ranges to increase resolution.
 +
<maxpat>
 +
<pre><code>
 +
----------begin_max5_patcher----------
 +
1249.3oc0Z1rbihCDG+r8SQWbYOrdcg9fu1a66vV0dXqolRFTr0TXvEHbR1o
 +
l28skDNwdljXLFiIyAbQOBn0OZ0+6VjuOel2pxmj0dveB+KLa12mOal0jwvr
 +
1ym4sU7TZtn1NLuzxsakEZuEt+Os7Is09euQUC6kU0pxB3QUdNrVpAcI3Chh
 +
Lfr.V0ngrRYcwuog0p8RnoFzprmgJYcSttd4g6YtpPlV1TXuwrViOTVnqU+m
 +
zXiPW5evb05UFS9uXYmPmtQUr9qUxTsalQHjkzfEPPbBNLfDXFMviV5Ceo8p
 +
JZ1pJxkZ6jj7pwxF8Aq9G4IEhsVOw6upTh7CNtJyZqb029CBO9f0c37CIlPi
 +
j4Dmh5bpDq2b3.7EyU8i4yMGVzwWJnitRV48wn5M.C0xiPRj4mHl4H0+bTYm
 +
nBm8ZY0WkEhU4xiYyoDi1Z0YR+7No6w5oLAPf2JQwZuWdXcjqImgqLe2bJ9p
 +
o5C4k374xoZazVXbfMZy2ez3J5whdS1.+yEwRamWgWMZwbA5xBuyxvfvWBJ6
 +
BBOESj2CSmRmSX.oaLHHje8KZkOhOyeIQZcpHWhYMSvaLPV1+vu.ZmB+BuL1
 +
cwQUTugiMUnTR4VbN0apzJADF8wPgdYPwjO6R4BqiQZCf7P20rKKxeFjnITT
 +
VjtAVlr.D0PK2cCoQuCUx2Kxaj0PyNiFOAxk0nZ9FQAdPBhp0Mlm3aKoyGPI
 +
cNicjjdn+MURO5bROt2UTN6NqnyCIehTzomUQmsLBeWSiit2Z5AN99oQSmet
 +
rLTmXNKHXzzz49QiplNm2MFPYraslNw+JE04IgSAQcdPGCqnzaERu9RAZkNt
 +
+kBvC8FPQ8+AkeyvFtM5xFs3VPg+rVB0FaBM7nDRQsZSK53OnfeAjo1qxjXq
 +
5l9zE43Hq0F89MJMp4WA4kOZ6jeiZ8lV0+2VdOXHj2ayQvBNRcOheSU2ICXg
 +
p+NPt73RWNXJK1szYYv8MrjkzGfrEKDTrV9KDASYg+qGKVccZQhsYRBHtSFH
 +
pbwHIdvQReReEcDQ376KQhFZhb4.I5Xdvhtu7Hbf4wkiCN8XbXSib+vQvY6x
 +
ssRlquK22Gh8HjZBgP9.pKodsfgKVWxO1vgIftT+1Qo91PM206YB8ySG0zdk
 +
DpusFaWqvB8+T0XrOaPq4dCV.cZYwdYkFgCHNT0sKpyTJt.r96B34xFas2oa
 +
rUjaKQWVWl2XxLBkOXsXGKr5YPUjVIE0laZaw730fCxc+ucexLWBPZ7QUgeS
 +
+dYI8pNhytkCQGUQ8XsgCIIdSocNvs7jFME12.rblgeG.H8jITWmE2+9+8Oo
 +
yS6EaWP+SeWd67vX+TTUiMmmd3o+xmV.dc1jIwF4KrEdcxnnmLpMpLr6+iW2
 +
lopMYlsNp+a9Zq6dDsSdj+H5QchQlO17n4QjNwH134Q7vNwnfQzi3cxiBmbL
 +
ZDWq8SuOdOOZDiiXcZ0uoUWf9AdzVU1tRL8ZaZQL6sotbV6W41UX9ImwHtOF
 +
V7xDyNsPas7piLfSwjNMEMKwISInyFwDbrNs3kMhKUXASNOJbx4QQSNOJdp4
 +
Q99cZ0+Hlx0mz4TtiiGkz8DjSJDQ6asDtx3E61092Wi0cLNC1ay2JqdoYKTV
 +
qvcpskBuJ4d0gwaaj2STgsunwdWZpbMR7TrY+cvmyOl++TzHK7A
 +
-----------end_max5_patcher-----------
 +
</code></pre>
 +
</maxpat>
 +
 +
Random tries to create true random numbers within its range, which means that a repeat number is just as likely as any other number. For random numbers without repetition, look at {{maxword|name=urn}}.
  
 +
If you are working in VIZZIE and want some random behaviors, look at vz.jittr, which introduces noise into any signal (within the standard vizzie data range of 0. - 1.) and vz.wandr, which emulates the behavior of {{maxword|name=drunk}} (also in the 0. - 1. data range.)
 
==Third-Party Max externals similar to the {{maxword|name=random}} object==
 
==Third-Party Max externals similar to the {{maxword|name=random}} object==
  
Line 12: Line 129:
  
 
==People who looked at/used this object also looked at....==
 
==People who looked at/used this object also looked at....==
 +
*{{maxword|name=decide}}
 +
*{{maxword|name=drunk}}
 +
*{{maxword|name=jit.noise}}
 +
*{{maxword|name=rand~}}
 +
*{{maxword|name=urn}}
  
 
==Errors or Clarifications==
 
==Errors or Clarifications==

Revision as of 21:00, 7 August 2013

Contents

random online refpage

Using the random object

The random object generates a random value from 0 to 1 less than the value specified by the argument.

random Tutorials

The random object shows up in many tutorials and example patches. The following tutorials represent particularly useful techniques for using the object.

All of the CyclistMusic patches use random in multiple places within the patches. These are a great way to get a sense of how to use the object in general and more specifically, how to incorporate randomization into timing, note selection, and other musical vocabularies.

  • ./examples/sequencing-looping/CyclistMusic


random Tips and Workarounds

The output of random is always an integer and always outputs values from 0 to 1 less than the range specified by the argument. In many cases you will want to convert these values to floating point or to offset them in some way, whether it is to control vizzie objects, OpenGL parameters or coordinates, to generate negative values, or even just to start from 1 instead of 0. In many cases you can do this by simply re-scaling the values using a scale object or by adding an offset with the + object.

-- Pasted Max Patch, click to expand. --

This patch shows a simple way to use the random object to create an adaptive probability system. Similar to the functionality of decide, it chooses between two possible states, however, each time one state is selected it is more likely to be selected again.

-- Pasted Max Patch, click to expand. --

This may seem obvious, but when converting the output of random to floats, you can use large ranges to increase resolution.

-- Pasted Max Patch, click to expand. --

Random tries to create true random numbers within its range, which means that a repeat number is just as likely as any other number. For random numbers without repetition, look at urn.

If you are working in VIZZIE and want some random behaviors, look at vz.jittr, which introduces noise into any signal (within the standard vizzie data range of 0. - 1.) and vz.wandr, which emulates the behavior of drunk (also in the 0. - 1. data range.)

Third-Party Max externals similar to the random object

Maxobjects.com listing for the random object

People who looked at/used this object also looked at....

Errors or Clarifications

(please list things that you believe to be errors or omissions from the existing refpage)