I'm working on a stereo program that carries the dry signal through, left input to left output & right input to right output. Obviously this isn't a problem mapping the inputs to the outputs, but I'm having an issue when the user unplugs the right input, I'd like for the left input to be mapped to both the left and right outputs.
At this point the following code shown below works when the right input is unplugged, however I'm having a problem when the right input is plugged in. The code below reads in the right input signal, and compares against a threshold, if above the threshold (we have signal) and we send the right input to the right output. If it is below the threshold (we don't have signal) it skips over sending the right input to right output and sends the left input to the right output. All of this seems to be working however I'm getting some crackle/distortion in one of my output channels. It does this whenever the signal is getting quieter, which I'm assuming its happening when the signal is bordering the threshold (possibly rapidly bouncing above and below the threshold). Does anyone know what's going on or if my code below looks incorrect?
Code: Select all
ldax adcr ; Read in right channel of ADC
absa ; Take absolute value of the signal
rdfx f1, fc_60Hz ; Apply LPF at 60Hz to get envelop of signal
wrax f1, 1.0
sof 1, -0.004 ; If envelop of signal is less than 0.004,
skp neg, noSig ; Skip ahead to noSig
; If here, signal is present at right input
clr
rdax adcr, 1
mulx clean_out
rdax r_revout, 1 ;Read output from Reverb and write it to ACC.
rdax l_modout, 1 ;Read output from Modulation and write it to ACC.
wrax dacr, 0 ;Write the ACC on DACR and clear it
skp zro, end
noSig: ; If here, nothing is plugged into the right input
clr
rdax adcl, 1
mulx clean_out
rdax l_revout, 1 ;Read output from Reverb and write it to ACC.
rdax l_modout, 1 ;Read output from Modulation and write it to ACC.
wrax dacr, 0 ;Write the ACC on DACL and clear it.
end: