How Can I Make My Vocoder More Efficient

Hi, I’m working on a basic vocoder and I’m having some issues with crackling. The crackles reduce when I reduce my ksmps but right now I have to have my ksmps set pretty high so that the vocoder has more detail. It may also be an issue with how I’m handling my kVoc variable that’s causing some crackles. Let me know if you have any ideas on how to improve the instrument.

<CsoundSynthesizer>
<CsOptions>
-odac -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5 -F MidiTest.mid
</CsOptions>

<CsInstruments>


sr = 44100
ksmps = 258
nchnls = 2
0dbfs = 1

massign 0, 1

giIndex init 0
giNumBands = 256
gaArr[] init giNumBands


instr 1 
  inote cpsmidi    ; get midi note number
  ichn midichn     ; get midi channel
  iamp ampmidi .1
  iOctaves = 3
  
  ; First, create all oscillators at init time
  iIndex = 0
  until iIndex >= iOctaves do
  	imode = 0
  	if iIndex == 0 then
  	imode = 0
  	endif
  	if iIndex < 3 && iIndex > 0 then
  	imode = 1
  	endif
  	if iIndex == 3 || iIndex > 3 then
  	imode = 2
  	endif

    instrnum = 2 + (ichn/100) + (inote/10000) + (iIndex/1000000)
 
    event_i "i", instrnum, 0, -1, iamp, inote * (iIndex + 1), imode, giIndex
    giIndex += 1
    iIndex += 1
  od
  

  krel release
  if (krel == 1) then
  
    kndx = 0
    while (kndx < iOctaves) do
      kinstrnum = 2 + (ichn/100) + (inote/10000) + (kndx/1000000)
      event "i", -kinstrnum, 0, 1
      giIndex -= 1
      kndx += 1
    od
  endif
endin
instr Vox
;a1 inch 1
a1 diskin2 "TestVocal.wav", 1, 0, 1
aBand = a1
kfreqMin = 100
kfreqMax = 15000



kIndex = 0
until kIndex >= giNumBands do

kRatio = kfreqMax / kfreqMin
kExp = kIndex / (giNumBands - 1)  ;
 kFreq = kfreqMin * (kRatio ^ kExp)
 aBand = a1
        
        if (kIndex == 0) then
         
            aBand butterlp aBand, kFreq
        elseif (kIndex == giNumBands-1) then
        
            aBand butterhp aBand, kFreq
        else
     
            kQ = 5 + giNumBands/2  
            aBand butterbp aBand, kFreq, kFreq/kQ
        endif
        
     
        gaArr[kIndex] = aBand



kIndex += 1
od

endin



instr 2 

  
  ipitch = p5
  iamp = p4
  iLogPitch = log10(ipitch)
    iLogMin = log10(100)  
    iLogMax = log10(8000) 
    iNormalized = (iLogPitch - iLogMin) / (iLogMax - iLogMin)
    iBand = round(iNormalized * (giNumBands-1))
    iBand limit iBand, 0, giNumBands-1
  

aVoc = gaArr[iBand] * 10


kVoc rms aVoc, 10, 10


  
  aEnv linsegr 0, 0.005, 1, 0.1, 0
  a1 oscili iamp, ipitch
  a1 = a1 * aEnv * abs(kVoc)
  a1 clip a1, 1, .8
  outs a1, a1
endin

</CsInstruments>
<CsScore>
i "Vox" 0 3600

</CsScore>
</CsoundSynthesizer>