| Right you are, Steven. I was assuming (incorrectly) that because goto
combines both igoto and kgoto, that line would test gkSweep during the init
pass. It doesn't. This works as desired:
instr 11
isweep = i(gkSweep)
if (isweep < 0) goto nosweep
setscorepos 8.5
nosweep:
endin
I was thinking that a better way to use setscorepos conditionally would be
to invoke the instrument that contains it from an event or scoreline opcode.
But this turns out to be problematical as well. Consider this code:
giSine ftgen 0, 0, 8192, 10, 1
instr 1
ktrig init 1
if ((p4 < 500) || (ktrig == 0)) goto noset
schedkwhen ktrig, 2, 1, 11, 0.5, 0.1, 1.5
printks "ktrig is %d\n", 0, ktrig
ktrig = 0
noset:
a1 oscil 0.5, p4, giSine
outs a1, a1
endin
instr 11
setscorepos p4
endin
i1 0 1 220
i1 2 1 330
i1 4 1 440
i1 6 1 550
e
What I would (naively) expect would be that the line containing schedkwhen
would run only when the fourth note (whose p4 is > 500) is playing, and that
that would set the score position backward to 1.5, causing a loop. But
that's not what happens. What happens is that instr 11 runs IMMEDIATELY,
even though schedkwhen has not yet called it. If you watch the print
statement, you'll see that the if/goto block is only running for the fourth
note -- and yet instr 11, which has not yet been run, causes a change in the
score position.
I guess I'm still struggling to understand the utility of this opcode.
--
View this message in context: http://csound.1045644.n5.nabble.com/setscorepos-tp5714221p5714231.html
Sent from the Csound - General mailing list archive at Nabble.com.
|