;@ map PANLOG PANLIN

;@ ins k k k
;@ outs k
opcode XFade, 0, kkkkkkk
  kmod,kMix,kLogLin, kin1,kin2,kmodin,kout xin
  kIn1 zkr kin1
  kIn2 zkr kin2
  kMod zkr kmodin

  kM = kmod * kMod ;* 1/64

  if kLogLin != 0 goto Next
    kPL table kMix+kM, giPANLOG
    kPR table (127-kMix-kM), giPANLOG
    goto Over
  Next:
    kPL table kMix+kM, giPANLIN
    kPR table (127-kMix-kM), giPANLIN
  Over:

  kO = kPL * kIn1 + kPR * kIn2

  zkw kO, kout
endop

;@ ins a a a
;@ outs a
opcode XFade, 0, kkkkkkk
  kmod,kMix,kLogLin, kin1,kin2,kmodin,kout xin
  aIn1 zar kin1
  aIn2 zar kin2
  aMod zar kmodin

  aM = kmod * aMod ;* 1/64

  if kLogLin != 0 goto Next
    aPL table kMix+aM, giPANLOG
    aPR table (127-kMix-aM), giPANLOG
    goto Over
  Next:
    aPL table kMix+aM, giPANLIN
    aPR table (127-kMix-aM), giPANLIN
  Over:

  aO = aPL * aIn1 + aPR * aIn2

  zaw aO, kout
endop
