GEN40

GEN40 — Generates a random distribution using a distribution histogram.

Description

Generates a continuous random distribution function starting from the shape of a user-defined distribution histogram.

Syntax

f # time size 40 shapetab

Performance

The shape of histogram must be stored in a previously defined table, in fact shapetab argument must be filled with the number of such table.

Histogram shape can be generated with any other GEN routines. Since no interpolation is used when GEN40 processes the translation, it is suggested that the size of the table containing the histogram shape to be reasonably big, in order to obtain more precision (however after the processing the shaping-table can be destroyed in order to re-gain memory).

This subroutine is designed to be used together with cuserrnd opcode (see cuserrnd for more information).

Examples

Here is an example of the GEN40 generator. It uses the file gen40.csd.

Example 1297. Example of the GEN40 generator.

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 realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o GEN40.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1	; every run time same values

kuser cuserrnd 0, 100, 1
      printk .2, kuser
asig  poscil .5, 220+kuser, 3
      outs asig, asig
endin

instr 2	; every run time different values

      seed 0
kuser cuserrnd 0, 100, 1
      printk .2, kuser
asig  poscil .5, 220+kuser, 3
      outs asig, asig
endin
</CsInstruments>
<CsScore>
f 1 0 16 -7 1 4 0 8 0 4 1	;distrubution using GEN07
f 2 0 16384 40 1		;GEN40 is to be used with cuserrnd
f 3 0 8192 10 1			;sine

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


Its output should include lines like these:

 i   1 time     0.00067:    53.14918
 i   1 time     0.20067:     0.00000
 i   1 time     0.40067:     0.00000
 i   1 time     0.60067:    96.80406
 i   1 time     0.80067:    94.20729
 i   1 time     1.00000:     0.00000
 i   1 time     1.20067:    86.13032
 i   1 time     1.40067:    31.37096
 i   1 time     1.60067:    70.35889
 i   1 time     1.80000:     0.00000
 i   1 time     2.00000:    49.18914

WARNING: Seeding from current time 2006647442

 i   2 time     3.00067:    21.45002
 i   2 time     3.20067:    44.32333
 i   2 time     3.40067:    46.05420
 i   2 time     3.60000:     0.00000
 i   2 time     3.80067:    41.32175
 i   2 time     4.00000:     0.00000
 i   2 time     4.20000:    63.72019
 i   2 time     4.40067:     0.00000
 i   2 time     4.60067:     0.00000
 i   2 time     4.80067:     0.00000
 i   2 time     5.00000:    74.49330
      

This is the diagram of the waveform of the GEN40 routine, as used in the example:

f 2 0 16384 40 1

f 2 0 16384 40 1

Credits

Author: Gabriel Maldonado