instrnum -- Number of the instrument to be called.
“insname” -- A string (in double-quotes) representing a named instrument.
Performance
a1, ..., a8 -- The audio output from the called instrument. This is generated using the signal output opcodes.
p4, p5, ... -- Additional input values the are mapped to the called instrument p-fields, starting with p4.
The called instrument's p2 and p3 values will be identical to the host instrument's values. While the host instrument can control its own duration, any such attempts inside the called instrument will most likely have no effect.
Examples
Here is an example of the subinstr opcode. It uses the file subinstr-modern.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in-odac
; -iadc ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o subinstr.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=1; Instrument #1 - Creates a basic tone.instr1; Print the value of p4, should be equal to; Instrument #2's amp field.print(p4); Print the value of p5, should be equal to; Instrument #2's pch field.print(p5); Create a tone.out(oscils(p4,p5,0))endin; Instrument #2 - Demonstrates the subinstr opcode.instr2amp:i=20000pch:i=440; Use Instrument #1 to create a basic sine-wave tone.; Its p4 parameter will be set using the amp variable.; Its p5 parameter will be set using the pch variable.basic:a=subinstr(1,amp,pch); Output the basic tone that we have created.out(basic)endin</CsInstruments><CsScore>; Play Instrument #2 for one second.i201e</CsScore></CsoundSynthesizer>
Here is an example of the subinstr opcode. It uses the file subinstr.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in-odac -iadc ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o subinstr.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=1; Instrument #1 - Creates a basic tone.instr1; Print the value of p4, should be equal to; Instrument #2's iamp field.printp4; Print the value of p5, should be equal to; Instrument #2's ipitch field.printp5; Create a tone.asigoscilsp4,p5,0outasigendin; Instrument #2 - Demonstrates the subinstr opcode.instr2iamp=20000ipitch=440; Use Instrument #1 to create a basic sine-wave tone.; Its p4 parameter will be set using the iamp variable.; Its p5 parameter will be set using the ipitch variable.abasicsubinstr1,iamp,ipitch; Output the basic tone that we have created.outabasicendin</CsInstruments><CsScore>; Table #1, a sine wave.f1016384101; Play Instrument #2 for one second.i201e</CsScore></CsoundSynthesizer>
Here is an example of the subinstr opcode using a named instrument. It uses the file subinstr_named-modern.csd.
Example of the subinstr opcode using a named instrument.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in-odac
; -iadc ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o subinstr_named.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=1; Instrument "basic_tone" - Creates a basic tone.instrbasic_tone; Print the value of p4, should be equal to; Instrument #2's amp field.print(p4); Print the value of p5, should be equal to; Instrument #2's pch field.print(p5); Create a tone.out(oscils(p4,p5,0))endin; Instrument #1 - Demonstrates the subinstr opcode.instr1amp:i=20000pch:i=440; Use the "basic_tone" named instrument to create a ; basic sine-wave tone.; Its p4 parameter will be set using the amp variable.; Its p5 parameter will be set using the pch variable.basic:a=subinstr("basic_tone",amp,pch); Output the basic tone that we have created.out(basic)endin</CsInstruments><CsScore>; Play Instrument #1 for one second.i101e</CsScore></CsoundSynthesizer>
Here is an example of the subinstr opcode using a named instrument. It uses the file subinstr_named.csd.
Example of the subinstr opcode using a named instrument.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in-odac -iadc ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o subinstr_named.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=1; Instrument "basic_tone" - Creates a basic tone.instrbasic_tone; Print the value of p4, should be equal to; Instrument #2's iamp field.printp4; Print the value of p5, should be equal to; Instrument #2's ipitch field.printp5; Create a tone.asigoscilsp4,p5,0outasigendin; Instrument #1 - Demonstrates the subinstr opcode.instr1iamp=20000ipitch=440; Use the "basic_tone" named instrument to create a ; basic sine-wave tone.; Its p4 parameter will be set using the iamp variable.; Its p5 parameter will be set using the ipitch variable.abasicsubinstr"basic_tone",iamp,ipitch; Output the basic tone that we have created.outabasicendin</CsInstruments><CsScore>; Table #1, a sine wave.f1016384101; Play Instrument #1 for one second.i101e</CsScore></CsoundSynthesizer>