In the score we use r to repeat code. It seems the s line, marking end of a section, was missing in the floss tutorial.
# ex1D01.py
# Different Seed
from moduleCsound import *
tags(1)
header(ksmps=32)
add("""
instr generate
;get seed: 0 = seeding from system clock
; otherwise = fixed seed
seed p4
;generate four notes to be played from subinstrument
iNoteCount = 0
until iNoteCount == 4 do
iFreq random 400, 800
event_i "i", "play", iNoteCount, 2, iFreq
iNoteCount += 1 ;increase note count
enduntil
endin
instr play
iFreq = p4
print iFreq
aImp mpulse .5, p3
aMode mode aImp, iFreq, 1000
aEnv linen aMode, 0.01, p3, p3-0.01
outs aEnv, aEnv
endin
""")
tags(2)
add("""
;repeat three times with fixed seed
r 3
i "generate" 0 2 1
s
;repeat three times with seed from the system clock
r 3
i "generate" 0 1 0
""")
tags(3)
writeRun(__file__)
No comments:
Post a Comment