Csound Csound-dev Csound-tekno Search About

[Csnd] setscorepos

Date2012-07-15 15:42
Frommenno
Subject[Csnd] setscorepos
is this correct behavior? (this question alone shows that i do not think
so...)
The second note is never played.

Menno



; 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 poscil.wav -W ;;; for file output any platform



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

seed 0
gisine ftgen 0, 0, 2^10, 10, 1

instr 1

setscorepos 9
kfrq = p4
asig  poscil .8, 220, gisine
      outs asig, asig

endin



i1 0 3 220 
i1 10 1 110
e



--
View this message in context: http://csound.1045644.n5.nabble.com/setscorepos-tp5714221.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2012-07-16 02:12
FromJim Aikin
Subject[Csnd] Re: setscorepos
I suspect this opcode is designed to be used in an instrument by itself, as
the manual example vaguely implies. When I test it that way, it works as
expected. Here's an example. Only the first and last notes are played.






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

giSine	ftgen	0, 0, 8192, 10, 1

instr 1
a1	oscil	0.5, p4, giSine
	outs	a1, a1
endin

instr 11
setscorepos 8.5
endin




i1     0    2   220
i11	2.5	1
i1	3	2	330
i1	6	2	440
i1	9	2	550          





--
View this message in context: http://csound.1045644.n5.nabble.com/setscorepos-tp5714221p5714228.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2012-07-16 02:21
FromJim Aikin
Subject[Csnd] Re: setscorepos
What's slightly more problematical, and may be a bug, is that setscorepos
ALWAYS seems to do its thing, irrespective of whether the code ought to run.
Consider this emendation of the previous example:

instr 11
if (gkSweep < 3) goto nosweep
	setscorepos 8.5
nosweep:
endin

instr 21
gkSweep		oscil	1, 1, giSine
endin

You'll note that gkSweep is always less than 3, which means, unless I'm
having a brain-fart due to being a doddering ancient, that setscorepos
should never run. But it does run.

--
View this message in context: http://csound.1045644.n5.nabble.com/setscorepos-tp5714221p5714229.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2012-07-16 02:37
FromSteven Yi
SubjectRe: [Csnd] Re: setscorepos
Hi Jim,

setscorepos seems to run at init-time.  Since the if-statement is
k-rate, the opcodes within it will still get an init-pass called.  I
think it's just a coding issue then, that you'd have to write things a
bit differently to account for that.

Thanks,
steven

On Sun, Jul 15, 2012 at 9:21 PM, Jim Aikin  wrote:
> What's slightly more problematical, and may be a bug, is that setscorepos
> ALWAYS seems to do its thing, irrespective of whether the code ought to run.
> Consider this emendation of the previous example:
>
> instr 11
> if (gkSweep < 3) goto nosweep
>         setscorepos 8.5
> nosweep:
> endin
>
> instr 21
> gkSweep         oscil   1, 1, giSine
> endin
>
> You'll note that gkSweep is always less than 3, which means, unless I'm
> having a brain-fart due to being a doddering ancient, that setscorepos
> should never run. But it does run.
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/setscorepos-tp5714221p5714229.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>

Date2012-07-16 04:23
FromJim Aikin
Subject[Csnd] Re: setscorepos
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.