The Alternative Csound Reference Manual
Previous |  | Next

# random

random -- Generates is a controlled pseudo-random number series between min and max values.

## Description

Generates is a controlled pseudo-random number series between min and max values.

## Syntax

ar random kmin, kmax

ir random imin, imax

kr random kmin, kmax

## Initialization

imin -- minimum range limit

imax -- maximum range limit

## Performance

kmin -- minimum range limit

kmax -- maximum range limit

The random opcode is similar to linrand and trirand but sometimes I [Gabriel Maldonado] find it more convenient because allows the user to set arbitrary minimum and maximum values.

## Examples

Here is an example of the random opcode. It uses the files random.orc and random.sco.

Example 1. Example of the random opcode.

    /* random.orc */
    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      ; Generate a random number between 220 and 440.
      kmin init 220
      kmax init 440
      k1 random kmin, kmax

      printks "k1 = %f\\n", 0.1, k1
    endin
    /* random.orc */

    /* random.sco */
    ; Play Instrument #1 for one second.
    i 1 0 1
    e
    /* random.sco */

Its output should include lines like:

    k1 = 414.232056
    k1 = 419.393402
    k1 = 275.376373

## See Also

linrand, randomh, randomi, trirand

## Credits

Author: Gabriel Maldonado

Example written by Kevin Conder.

Previous | Home | Next
randi | Up | randomh