GEN41 — Generates a random list of numerical pairs.
The first number of each pair is a value, and the second is the probability of that value to be chosen by a random algorithm. Even if any number can be assigned to the probability element of each pair, it is suggested to give it a percent value, in order to make it clearer for the user.
This subroutine is designed to be used together with duserrnd and urd opcodes (see duserrnd for more information).
Here is an example of the GEN41 generator. Play gen41.csd
Example 1308. Example of the GEN41 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 RT audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o GEN41.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 k1 duserrnd 1 printk 0, k1 asig poscil .5, 220*k1, 2 outs asig, asig endin </CsInstruments> <CsScore> f1 0 -20 -41 2 .1 8 .9 ;choose 2 at 10% probability, 8 at 90% f2 0 8192 10 1 i1 0 2 e </CsScore> </CsoundSynthesizer>
Its output should include lines like these:
i 1 time 0.00067: 8.00000 i 1 time 0.00133: 8.00000 i 1 time 0.00200: 8.00000 i 1 time 0.00267: 8.00000 i 1 time 0.00333: 2.00000 i 1 time 0.00400: 8.00000 i 1 time 0.00533: 8.00000 i 1 time 0.00600: 8.00000 ..........
This is the diagram of the waveform of the GEN41 routine, as used in the example: