Skip to content

splice

Places an instrument instance before or after another in the performance list.

Syntax

iStatus = splice(voice, anchor, iMode)
iStatus splice voice, anchor, iMode

Initialization

voice is the Instr instance to place in the list. anchor is an Instr instance already in Csound's active performance list. Use distinct instances.

iMode selects the position. Use 0 to put voice immediately before anchor, or 1 to put it immediately after.

iStatus is 0 on success and -1 if Csound cannot place the instance. The operation runs once at initialization. It does not create or initialize either instance.

One use is to insert an instance made with create and init so that it runs before an instrument that reads its audio bus. Once inserted, Csound performs it automatically. Do not also call perf on it.

Examples

The controller creates a source and inserts it immediately before itself. The source writes to gaBus before the controller reads the bus and applies an envelope. It uses splice.csd.

Run a source before its bus reader
<CsoundSynthesizer>
<CsOptions>
-odac -d -m0
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 1
0dbfs = 1

gaBus init 0

instr Source
  gaBus poscil 0.1, 440
endin

instr 1
  source:Instr = create(Source)
  iStatus = init(source)
  ; Insert the new source immediately before this instrument.
  iStatus = splice(source, this, 0)
  if iStatus != 0 then
    exitnow -1
  endif

  ; Csound now performs source through its active list.
  ; Do not also call perf(source).
  aEnvelope linseg 0, 0.01, 1, p3 - 0.02, 1, 0.01, 0
  out gaBus * aEnvelope
  delete(source)
endin
</CsInstruments>
<CsScore>
i 1 0 1
e
</CsScore>
</CsoundSynthesizer>

See also

create, init, getinstance, delete, Instrument definitions, instances and opcode objects

Credits

Author Victor Lazzarini.

New in Csound 7.