Skip to content

nstrstr

Returns an instrument name from its number, or an empty string if no name matches.

instrstr is another name for this opcode in Csound 7.

Syntax

Sname = nstrstr(insno)
Sname = nstrstr(knsno)
Sname nstrstr insno
Sname nstrstr knsno

Initialization

insno -- the instrument number of the named instrument.

Performance

knsno -- the instrument number to look up on each control cycle. The i-rate form looks it up once at initialization.

Sname -- the named instrument's name.

If an instrument with the specified name does not exist an empty string is returned.

Examples

Here is an example of the nstrstr opcode. It uses the file nstrnum_nstrstr.csd.

Example of the nstrstr opcode.
<CsoundSynthesizer>
<CsOptions>
-n
</CsOptions>
<CsInstruments>

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

instr nothing
endin

instr john
 prints "instrument name = "
 puts nstrstr(p1),1
 prints "instrument number = %d\n", nstrnum("john")
endin

instr test
endin

</CsInstruments>
<CsScore>
i "john" 0 0
</CsScore>
</CsoundSynthesizer>

The example will produce the following output:

instrument name = john
instrument number = 2

See also

instrstr, instrnum, str

Credits

Author: John ffitch
New in version 6.13
Written in the year 2019.