randh
Prev | Orchestra Opcodes and Operators | Next

## randh

randh — Generates random numbers and holds them for a period of time.

## Description

Generates random numbers and holds them for a period of time.

## Syntax

    ares randh xamp, xcps [, iseed] [, isize] [, ioffset]

    kres randh kamp, kcps [, iseed] [, isize] [, ioffset]

## Initialization

iseed (optional, default=0.5) -- seed value for the recursive pseudo-random formula. A value between 0 and +1 will produce an initial output of kamp * iseed. A value greater than 1 will be used directly, without scaling. A negative value will cause seed re-initialization to be skipped. The default seed value is .5.

isize (optional, default=0) -- if zero, a 16 bit number is generated. If non-zero, a 31-bit random number is generated. Default is 0.

ioffset (optional, default=0) -- a base value added to the random result. New in Csound version 4.03.

## Performance

kamp, xamp -- range over which random numbers are distributed.

kcps, xcps -- the frequency which new random numbers are generated.

The internal pseudo-random formula produces values which are uniformly distributed over the range -kamp to +kamp. rand will thus generate uniform white noise with an R.M.S value of kamp / root 2.

The remaining units produce band-limited noise: the kcps and xcps parameters permit the user to specify that new random numbers are to be generated at a rate less than the sampling or control frequencies. randh will hold each new number for the period of the specified cycle.

## Examples

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

Example 313. Example of the randh opcode.

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

    ; Instrument #1.
    instr 1
      ; Choose a random frequency between 4,100 and 44,100.
      ; Generate new random numbers at 220 Hz.
      ; kamp = 40000
      ; kcps = 220
      ; iseed = 0.5
      ; isize = 0
      ; ioffset = 4100

      kcps randh 40000, 220, 0.5, 0, 4100

      a1 oscil 30000, kcps, 1
      out a1
    endin
    /* randh.orc */

    /* randh.sco */
    ; Table #1, a sine wave.
    f 1 0 16384 10 1

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

## See Also

rand, randi

## Credits

Example written by Kevin Conder.

Prev | Up | Next
rand | Home | randi