;@ map CLA001
;@ ins k k
;@ outs k
; TODO check modulation
opcode Clip, 0, kkkkkkk
  kMod, klev, kShape, kOn, kin, kmod, kout xin
  k1 zkr kin
  kM zkr kmod

  kModN table kMod, giCLA001
  kLev table klev + kM * kModN, giCLA001
  kLev *= .25 ; norm
  k1 limit k1, -0.25, 0.25 ; buit-in limiter before clipper

  if kShape == 0 goto Asym
    ko limit k1, -kLev, kLev
    goto Out
Asym:
    ko limit k1, -2, kLev ; no care about lower lim
Out:
    zkw ko, kout
endop

;@ ins a a
;@ outs a

opcode Clip, 0, kkkkkkk
  kMod, klev, kShape, kOn, kin, kmod, kout xin
  a1 zar kin
  aM zar kmod

  kModN table kMod, giCLA001
  aLev table klev + aM * kModN, giCLA001
  aLev *= .25 ; norm
  a1 limit a1, -0.25, 0.25 ; buit-in limiter before clipper

  if kShape == 0 goto Asym
    ao limit a1, -kLev, kLev
    goto Out
Asym:
    ao limit a1, -2, kLev ; no care about lower lim
Out:
    zaw ao, kout
endop
