René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

opcode (Csound opcode)

opcode opcode-name, outtypes, intypes
  xinarg1 [, xinarg2] [, xinarg3] ... [xinargN]  xin
  [setksmps  iksmps]

  ; use xinarg1 .. xinargN and create xoutarg1 .. xoutargN

  xout  xoutarg1 [, xoutarg2] [, xoutarg3] ... [xoutargN]
endop
Each expected in-type and out-type is indicated by exactly one character.
For out-types, these characters are one of
  • a
  • i
  • k
  • K
For in-types, these characters are one of
  • a
  • i
  • j
  • k
  • K
  • o
  • p

An example

opcode.sco
sr     = 44100
kr     = 44100
nchnls =     1

opcode sign, k, a
  ain xin

  kin downsamp ain

  if kin > 0 then
    kout = 1
  elseif kin = 0 then
    kout = 0
  elseif kin < 0 then
    kout = -1
  endif

  xout kout
endop

opcode cut, a, ak
  asig, kcut xin

  ksig downsamp asig

  if abs(ksig) > abs(kcut) then
    acut interp kcut
    ksign1 sign asig
    aout = abs(acut)*ksign1
  else
    aout = asig
  endif

  xout aout
endop

instr 1
  ilen = p3
  iamp = p4
  ifrq = p5

  kenv oscili 1, 1/ilen, 1
  asin oscili 1, ifrq, 1

  asig cut asin, kenv

  out asig*iamp
endin
opcode.sco
f1 0 2048 10 1

i1 0 0.1   10000 440