Use Non-Frames Version Previous Page Next Page
Appendix: DirectCsound

call, calld, callm, callmd

          call      instrno, iactime, idur[, ip4, ip5,..., ipn]
          calld     instrno, iactime, idur[, ip4 , ip5 ,..., ipn]
          callm     instrno, iactime[, ip3, ip4,ip5,..., ipn]
          callmd    instrno, iactime, idur[, ip4, ip5,..., ipn]

Description

Activate an instrument from within another instrument at performance time(subroutine call)

Initialization

instrno - instrument number to be activated

iactime - action time in seconds (should be zero when using call)

idur - duration of the note to be activated

ip3, ip4, ip5, ..., ipn - p-fields of the instrument to be activated

Performance

An instrument containing call (instrument call), calld (delayed instrument call), callm (MIDI-oriented instrument call) orcallmd (delayed MIDI-oriented instrument call) opcodes, can activate an instance of another instrument of the same orchestra during the performance.

These opcodes can be thought of as subroutine calls. Any number of additional init-rate arguments (ip4,ip5,ip6 etc.) can be sent to the target instruments, in the same way as p-fields in a score note event.

More instances of call, calld, callm and callmdcan coexist in the same calling instrument, so chords of more notes (played by different target instruments) can be activated by a single MIDI note-on event, as well as by a single i-statement in the score. This possibility allows the user to do several things, for example, to easily implement multi-layered instruments, or to inherit the features of one instrument by a more specialized instrument (by using these opcodes together with the parmXX and rtrnXX opcode family, see below).

Multiple inheritance of several instruments can be also implemented by using these opcodes in Csound.

call plays the target note immediately (so iactime argument must be set to zero), and its duration is idur seconds, even if the calling instrument is turned off beforehand or afterward. This opcode has no output and operates at i-rate only.

calld can schedule the target note activation 'iactime' seconds after the caller instrument init-time. Again, the target note duration is 'idur' seconds, even if the caller instrument is turned off beforehand or afterward. This opcode has no output and operates at k-rate.

callm plays the target note immediately (so iactime argument must be set to zero), but its duration is indeterminate and depends by a midi midi note-off message recognized by the caller instrument. This opcode is useful when the caller instrument is activated by MIDI. In fact in this case it is impossible to know the caller duration beforehand. Notice that it is still possible to use call and calld with a MIDI-activated caller instrument instead of callm. In that case the target notes will be simply turned off after idur seconds, whether the caller instr is turned off before or after idur seconds are elapsed or it isn't. callm has no output and operates at k-rate.

callmd can schedule the target note activation iactime seconds after the caller instrument init-time. The duration of the target note is indeterminate (so idur parameter is meaningless) and depends by a midi note-off message recognized by the caller instrument. The target note is not allocated until iactime seconds are elapsed. callmd has no output and operates at k-rate.

Notice that each of these opcodes makes the processing point not to return to the caller until all the target instrument initializations have been completed.

Examples

;EXAMPLE 1: call and calld =====================

  gifn    ftgen     1,0,1024,10,1,0,0,0,0,0,0,.5,0,0,0,0,0.2

instr   1       ;caller instrument 
  ifreq   cpsmidi	
          call      2,0,2, 2000,ifreq	
          calld     2,1,4, 2000,ifreq*1.2	
          calld     2,3,6, 2000,ifreq*1.77	
          calld     2,5,8, 2000,ifreq*2.1	
          calld     2,8,10,2000,ifreq*2.4555
endin

instr   2       ;target instrument 
  k1      linseg    0,p3/2,1,p3/2,0
  a1      oscili    p4,p5,gifn      
          out       a1*k1   
endin

;EXAMPLE 2: callm and callmd ==================

  gifn    ftgen     1,0,1024,10,1,0,0,0,0,0,0,.5,0,0,0,0,0.2
  
instr   1       ;caller instrument 
  iamp	  ampmidi   2000
  ifreq	  cpsmidi	
          callm     2,0,2 ,iamp,      
  ifreq	  callmd    2,1,4 ,iamp * .5, ifreq * 1.2	
          callmd    2,3,6 ,iamp * .25,ifreq * 1.77	
          callmd    2,6,8 ,iamp * .2, ifreq * 2.1	
          callmd    2,8,10,iamp * .1, ifreq * 2.4555        
endin

instr   2       ;target instrument 
  k1      linenr    1,p3/2,p3/2,.03
  a1	    oscili    p4,p5,gifn	
          out     a1*k1	
endin


Use Non-Frames Version Previous Page Next Page
Appendix: DirectCsound