;@ map AMPEXP CLA001 AMPEXP
;@ map BUT002
;@ map BUT003

;@ ins k k k k k
;@ outs k
opcode Mix41C, 0, kkkkkkkkkkkkkkkk
kL1,kL2,kL3,kL4,kO1,kO2,kO3,kO4,kPad,kExpLin,kI1,kI2,kI3,kI4,kCh,kOut  xin
	k1 zkr kI1
	k2 zkr kI2
	k3 zkr kI3
	k4 zkr kI4
	k5 zkr kCh

  ; Pad =       0, -6db   Pad doesn't affect Chain!
  kP[] fillarray 1,0.5

	if kExpLin == 1 goto Out
    kL1 table kL1, giAMPEXP
    kL2 table kL2, giAMPEXP
		kL3 table kL3, giAMPEXP
		kL4 table kL4, giAMPEXP
  Out:
		kL1 table kL1, giCLA001
		kL2 table kL2, giCLA001
		kL3 table kL3, giCLA001
		kL4 table kL4, giCLA001
	Next:
	kout = kP[kPad]*(k1*kL1*kO1 + k2*kL2*kO2 + k3*kL3*kO3 + k4*kL4*kO4) + k5
	kout limit kout, -4, 4
	zkw kout, kOut
endop

;@ ins a a a a a
;@ outs a
opcode Mix41C, 0, kkkkkkkkkkkkkkkk
kL1,kL2,kL3,kL4,kO1,kO2,kO3,kO4,kPad,kExpLin,kI1,kI2,kI3,kI4,kCh,kOut  xin
	a1 zar kI1
	a2 zar kI2
	a3 zar kI3
	a4 zar kI4
	a5 zar kCh

  ; Pad =       0, -6db   Pad doesn't affect Chain!
  kP[] fillarray 1,0.5

	if kExpLin == 1 goto Out
		kL1 table kL1, giAMPEXP
		kL2 table kL2, giAMPEXP
		kL3 table kL3, giAMPEXP
		kL4 table kL4, giAMPEXP
		goto Next
  Out:
		kL1 table kL1, giCLA001
		kL2 table kL2, giCLA001
		kL3 table kL3, giCLA001
		kL4 table kL4, giCLA001
	Next:
	aout = kP[kPad]*(a1*kL1*kO1 + a2*kL2*kO2 + a3*kL3*kO3 + a4*kL4*kO4) + a5
	aout limit aout, -4, 4
	zaw aout, kOut
endop
