[Csnd] Named instruments and fractional instance numbers

Hey hey,
I wondered what the most ellegant way is to schedule or schedulek a named instrument with a fractional part to denote a separate instance.

I've achieved it with an expression like this:
(nstrnum("Source") + (iIndex * .01))

It works, it's clear, but it seems a little long as part of a full schedule line in the score.

Is there a shorter way? A special syntax?

Best wishes,

Jeanette

Depeding on our version try foo.3 as an instrumnt name

Nov 9 2021, john has written:

Depeding on our version try foo.3 as an instrumnt name

Does that work out with dynamic fractional instrument numbers? Would I have to sprintf it in that case?

afaik it is static if it works at all

==John ff

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

i was curious about this and wrote some test code:

<CsoundSynthesizer>
<CsOptions>
-o dac
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

instr Call
  schedule "Test.1", 0, 99, 400
  schedule "Test.2", 0, 99, 500
  schedule "Kill", 3, 1
endin

instr Kill
  turnoff2 "Test.1", 4, 0
  turnoff
endin

instr Test
  prints "Instrument is: '%s'\n", nstrstr(p1)
  aOut poscil .2, p4
  out aOut, aOut
endin

</CsInstruments>
<CsScore>
i "Call" 0 1
</CsScore>
</CsoundSynthesizer>

as far as i see, the result is:
- it works if the fractional part is inside the string, but
- turnoff2 is not able to distinguish between instances, because the fractional part seems not to arrive in the called instrument properly.

so i think the only clean way is to do what jeanette did. i'd wrap it in a UDO, like:

<CsoundSynthesizer>
<CsOptions>
-o dac
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

opcode NamedFrac, i, Si
  Sinstr, iFrac xin
  xout nstrnum(Sinstr) + iFrac
endop

instr Call
  schedule NamedFrac("Test",.1), 0, 99, 400
  schedule NamedFrac("Test",.2), 0, 99, 500
  schedule "Kill", 3, 1
endin

instr Kill
  turnoff2 NamedFrac("Test",.1), 4, 0
  turnoff
endin

instr Test
  prints "Instrument is: '%f'\n", p1
  aOut poscil .2, p4
  out aOut, aOut
endin

</CsInstruments>
<CsScore>
i "Call" 0 1
</CsScore>
</CsoundSynthesizer>

best -
  joachim

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

Likely there is a cast from YFLT to int which loses te fractional part. I seem to remember noticing this but it was not my code.....