Csound Csound-dev Csound-tekno Search About

[Csnd] Using compilestr in a subinstr doesn't work

Date2021-10-17 01:23
FromRichard Knight
Subject[Csnd] Using compilestr in a subinstr doesn't work
Hi,
I have noticed that when using compilestr in a subinstr, it only seems 
to run the init pass of the sub instrument then turns off. I suppose 
using compilestr in a sub instrument is not really an ideal design 
pattern, but would be interested to know if this is expected/intended 
behaviour:



instr 1
	ires compilestr "instr 99\nout oscil(0.5, 440)\nendin"
	print ires
	printks "k\n", 0.1
	a1 oscil 0.5, 880
	out a1
endin

instr 2
	a1 subinstr 1
	out a1
endin


i2 0 1  ; no audio, ires=0 , 'k' not printed
i1 1 1  ; audio , ires=0 , 'k' printed
i2 2 1  ; exits immediately





; also doesn't work with subinstrinit in separate compile pass attempt, 
but the string is compiled

instr 1
	icompile = p4
	if (icompile == 1) then
		ires compilestr "instr 99\nout oscil(0.5, 440)\nendin"
		print ires
	endif
	printks "k\n", 0.1
	a1 subinstr 99
	out a1
endin

instr 2
	subinstrinit 1, 1
	a1 subinstr 1, 0
	out a1
endin

instr 3
	a1 subinstr 99
	out a1
endin


i2 0 1   ; no audio, ires=0 , 'k' not printed
i1 1 1 0 ; audio (so i99 did compile above) , 'k' printed
i3 2 1   ; audio
i2 3 10  ; exits immediately

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here