random
Prev | Orchestra Opcodes and Operators | Next

## random

random — Generates 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

    ares random kmin, kmax

    ires random imin, imax

    kres 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 file random.csd.

Example 385. Example of the random opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    ; Audio out   Audio in
    -odac           -iadc    ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o random.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; 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

    </CsInstruments>
    <CsScore>

    ; Play Instrument #1 for one second.
    i 1 0 1
    e

    </CsScore>
    </CsoundSynthesizer>

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.

Prev | Up | Next
randi | Home | randomh