getseed

getseed — Reads the global seed value.

Description

Returns the global seed value used for all x-class noise generators.

Syntax

ians getseed
kans getseed

Performance

Reads the global seed value of the internal pseudo-random number generator.

Examples

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

Example 424. Example of the getseed 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 getseed.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

; by Menno Knevel - 2021

seed 0    ; use seed from system clock

instr 1   ; different values every time - value is derived from system clock

krnd  randomh 100, 400, 1		
      printks2    "different values every time Value = %d\n ",  krnd	
aout  poscil 0.8, 440+krnd
      outs aout, aout
endin

instr 2   ; same values every time - captured by getseed

gised getseed                 ; capture the clock seed value and make it a global value
seed  gised                   ; so that it can be used in all instruments
print gised
krnd  randomh 100, 400, 1		
      printks2    "get seed value from time clock. Value = %d\n ",  krnd	
aout  poscil 0.8, 440+krnd
      outs aout, aout
endin

instr 3	; same values every time - captured by getseed

print gised                   ; check the global seed value
seed  gised                   ; let the seed get this value
krnd  randomh 100, 400, 1		
      printks2    "re-uses seed value of instr 2. Value = %d\n ",  krnd	
aout  poscil 0.8, 440+krnd
      outs aout, aout
endin


</CsInstruments>
<CsScore>

i1 0 3  ; 2 notes showing the different
i1 5 3

i2 10 3 ; 1 note & get the seed value

i3 15 3 ; 1 note and use that seed value again
e
</CsScore>
</CsoundSynthesizer>


Credits

Author: John ffitch
University of Bath/NUIM/Codemist Ltd.
Bath, UK
August 2015

New in Csound6.06