;@ map PANLOG PANLIN

;@ ins k k
;@ outs k k
opcode Pan, 0, kkkkkkk
  kmod,kPan,kLogLin, kin,kmodin,koutL,koutR xin
  kIn zkr kin
  kMod zkr kmodin

  kM = kmod * kMod ;* 1/64

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

  kL = kPL * kIn
  kR = kPR * kIn

  zkw kL, koutL
  zkw kR, koutR
endop

;@ ins a a
;@ outs a a
opcode Pan, 0, kkkkkkk
  kmod,kPan,kLogLin, kin,kmodin,koutL,koutR xin
  aIn zar kin
  aMod zar kmodin

  aM = kmod * aMod ;* 1/64

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

  aL = aPL * aIn
  aR = aPR * aIn

  zaw aL, koutL
  zaw aR, koutR
endop
