Skip to content

nstrnum

Returns the number of a named instrument.

Syntax

insno nstrnum "name"

Initialization

insno -- the instrument number of the named instrument.

Performance

"name" -- the named instrument's name.

If an instrument with the specified name does not exist, an init error occurs, and -1 is returned.

Examples

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

Example of the nstrnum 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

A musical examples featuring the nstrnum opcode: TivalNstrnum_Yi.csd by Steven Yi.

See also

Initialization and Reinitialization

Credits

Author: Istvan Varga
New in version 4.23
Written in the year 2002.