Modified x-class noise page - derived from the Csound 3.48 manual page xnoise.html- Robin Whittle 6 July 1998

QUICK-REF - CsoundManual - Top of this section - Previous - Contents - Index - Next Section

## x-class noise

xunirand        krange
xbunirand       krange

xlinrand        krange
xtrirand        krange

xexprand        krange
xbexprnd        krange

xcauchy         kalpha
xpcauchy        kalpha

xpoisson        klambda
xgauss          krange
xweibull        ksigma, ktau
xbeta           krange, kalpha, kbeta

seed            iseed

#### DESCRIPTION

All of the following opcodes operate in i-, k- and a-rate. The output rate depends on the first letter of the opcode, a for a-rate, k for k- rate and i for i-rate. krange can be i- or k-rate.  They share a common 31 bit Pseudo Random Number Generator (PRNG) with a long repeat cycle of 2,147,483,647 = (2^31 - 1) numbers.

xuniform krange - Uniform distribution random number generator. krange is the range of the random numbers (0 to krange). For instance with krange = 7, the output values will be uniformly distrubuted between 0 and 7.

xbuniform krange - Bipolar Uniform distribution random number generator. AKA white noise.  krange is the range of the random numbers (-krange to +krange). For instance with krange = 1, the output values will be uniformly distributed between -1 and +1.

xlinrand krange - Linear distribution random number generator. krange is the range of the random numbers (0 - krange). "Linear" refers to the slope of the distribution curve.  For instance with krange = 10 there is a high probability of the numbers being close to zero and a low probability of them being close to 10.  The probability of the numbers falling in the number range  5 to  5.1 is about half that of them falling into the range 0 to 0.1.

xtrirand krange - Triangular distribution random number generator. Similar to xlinrand above, but outputs both negative and positive numbers in the range -krange to +krange.

xexprand krange - Exponential distribution random number generator. krange is the range of the random numbers (0 - krange). *

xbexprnd krange - Same as above, only extends to negative numbers too with an exponential distribution. *

xcauchy kalpha - Cauchy distribution random number generator. kalpha controls the spread from zero (big kalpha => big spread). Outputs both positive and negative numbers.

xpcauchy kalpha - Same as above, ouputs positive numbers only.

xpoisson klambda - Poisson distribution random number generator. klambda is the mean of the distribution. Outputs only positive numbers.

xgauss krange - Gaussian distribution random number generator. krange is the range of the random numbers (-krange - 0 - krange). Outputs both positive and negative numbers.

xweibull ksigma, ktau - Weibull distribution random number generator. ksigma scales the spread of the distribution and ktau, if greater than one numbers near ksigma are favored, if smaller than one small values are favored and if t equals 1 the distribution is exponential. Outputs only positive numbers.

xbeta krange, kalpha, kbeta - Beta distribution random number generator. krange is the range of the random numbers [0 - krange). If kalpha is smaller than one, smaller values favor values near 0. If kbeta is smaller than one, smaller values favor values near krange. If both kalpha and kbeta equal one we have uniform distribution. If both kalpha and kbeta are greater than one we have a sort of gaussian distribution. Outputs only positive numbers.

seed iseed - Set the seed of the PRNG and display its value at the init time of the instrument is is used in. Normally this would only be done once in a piece.  If the seed opcode is not used, then the PRNG starts from a fixed seed. If iseed is 0, then the current time and date is used.  If iseed is any other value, then the seed is set with mod (2^31 - 1) abs(iseed * 1000).  So iseed values at 0.001 steps between 0.001 and about 2^24 produce unique seed values.  Above that floating point rounding increases the steps.  All these x-noise opcodes call the one PRNG which uses this seed - so if the noise and other non-deterministic compositional elements of a piece are controlled by the results of these opcodes, then different values of iseed will produce unique but reproducible musical results. The PRNG uses the Park Miller linear congruential algorithm, as described in  "Random Number Generators: Good Ones Are Hard to Find", S.K. Park and K.W. Miller, Communications of the ACM 31:10 (Oct 1988).  result = seed = (16807 * seed) mod (2^31 - 1).

* Note from Robin Whittle:  The xexprand and xbexprnd (note lack of "a") do not seem function as per these descriptions.  In the case of xexprand the return value is 0 minus the log of a number randomly between "0" and range but not including 0.  I have not tested the other opcodes, but have tested xunirand, xbunirand, xlinrand and xtrirand.

For more detailed explanation of these distributions, see:
1. C. Dodge - T.A. Jerse 1985. Computer music. Schirmer books. pp.265 - 286
2. D. Lorrain. A panoply of stochastic cannons. In C. Roads, ed. 1989. Music machine . Cambridge, Massachusetts: MIT press, pp. 351 - 379.

#### EXAMPLE:

a1  atrirand    32000         ; Audio noise with triangle distribution
k1  kcauchy     10000         ; Control noise with Cauchy dist.
i1  ibetarand   30000, .5, .5 ; i-time random value, beta dist.
AUTHOR:

Paris Smaragdis
MIT, Cambridge
1995

31 bit internal PRNG
Robin Whittle
Melbourne Australia
July 1998

QUICK-REF - CsoundManual - Top of this section - Previous - Contents - Index - Next Section
HTML Csound Manual - © Jean Piché & Peter J. Nix, 1994-97