| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
-odac ;;;realtime audio out |
| 5 |
;-iadc ;;;uncomment -iadc if RT audio input is needed too |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o getseed.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
|
| 11 |
sr = 44100 |
| 12 |
ksmps = 32 |
| 13 |
nchnls = 2 |
| 14 |
0dbfs = 1 |
| 15 |
|
| 16 |
; by Menno Knevel - 2021 |
| 17 |
|
| 18 |
seed 0 ; use seed from system clock |
| 19 |
|
| 20 |
instr 1 ; different values every time - value is derived from system clock |
| 21 |
|
| 22 |
krnd randomh 100, 400, 1 |
| 23 |
printks2 "different values every time Value = %d\n ", krnd |
| 24 |
aout poscil 0.8, 440+krnd |
| 25 |
outs aout, aout |
| 26 |
endin |
| 27 |
|
| 28 |
instr 2 ; same values every time - captured by getseed |
| 29 |
|
| 30 |
gised getseed ; capture the clock seed value and make it a global value |
| 31 |
seed gised ; so that it can be used in all instruments |
| 32 |
print gised |
| 33 |
krnd randomh 100, 400, 1 |
| 34 |
printks2 "get seed value from time clock. Value = %d\n ", krnd |
| 35 |
aout poscil 0.8, 440+krnd |
| 36 |
outs aout, aout |
| 37 |
endin |
| 38 |
|
| 39 |
instr 3 ; same values every time - captured by getseed |
| 40 |
|
| 41 |
print gised ; check the global seed value |
| 42 |
seed gised ; let the seed get this value |
| 43 |
krnd randomh 100, 400, 1 |
| 44 |
printks2 "re-uses seed value of instr 2. Value = %d\n ", krnd |
| 45 |
aout poscil 0.8, 440+krnd |
| 46 |
outs aout, aout |
| 47 |
endin |
| 48 |
|
| 49 |
|
| 50 |
</CsInstruments> |
| 51 |
<CsScore> |
| 52 |
|
| 53 |
i1 0 3 ; 2 notes showing the different |
| 54 |
i1 5 3 |
| 55 |
|
| 56 |
i2 10 3 ; 1 note & get the seed value |
| 57 |
|
| 58 |
i3 15 3 ; 1 note and use that seed value again |
| 59 |
e |
| 60 |
</CsScore> |
| 61 |
</CsoundSynthesizer> |