trirand
Prev | Orchestra Opcodes and Operators | Next

## trirand

trirand — Triangular distribution random number generator

## Description

Triangular distribution random number generator. This is an x-class noise generator.

## Syntax

    ares trirand krange

    ires trirand krange

    kres trirand krange

## Performance

krange -- the range of the random numbers (-krange to +krange).

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.

## Examples

Here is an example of the trirand opcode. It uses the file trirand.csd.

Example 1049. Example of the trirand 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
    -odac     ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if RT audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o trirand.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    instr 1  	; every run time same values

    ktri	trirand 100
    	printk .2, ktri			; look
    aout	oscili 0.8, 440+ktri, 1		; & listen
    	outs	aout, aout
    endin

    instr 2		; every run time different values

    	seed 0
    ktri	trirand 100
    	printk .2, ktri			; look
    aout	oscili 0.8, 440+ktri, 1		; & listen
    	outs	aout, aout
    endin

    </CsInstruments>
    <CsScore>
    ; sine wave
    f 1 0 16384 10 1

    i 1 0 2
    i 2 3 2
    e
    </CsScore>
    </CsoundSynthesizer>

Its output should include a line like this:

     i   1 time     0.00067:    -4.97993
     i   1 time     0.20067:     1.20909
     i   1 time     0.40067:    17.45873
     i   1 time     0.60067:    52.55409
     i   1 time     0.80067:    -1.92888
     i   1 time     1.00000:   -11.01149
     i   1 time     1.20067:     9.79521
     i   1 time     1.40067:    26.98504
     i   1 time     1.60067:    24.67405
     i   1 time     1.80000:   -67.59846
     i   1 time     2.00000:    64.24861
    WARNING: Seeding from current time 521999639
     i   2 time     3.00067:     3.28969
     i   2 time     3.20067:    54.98986
     i   2 time     3.40067:   -33.84788
     i   2 time     3.60000:   -41.93523
     i   2 time     3.80067:    -6.61742
     i   2 time     4.00000:    39.67097
     i   2 time     4.20000:     2.95123
     i   2 time     4.40067:    45.59255
     i   2 time     4.60067:    16.57259
     i   2 time     4.80067:   -18.80273
     i   2 time     5.00000:    -2.01697

## See Also

betarand, bexprnd, cauchy, exprand, gauss, linrand, pcauchy, poisson, unirand, weibull

## Credits

Author: Paris Smaragdis
MIT, Cambridge
1995

Prev | Up | Next
trim | Home | trlowest