In defence of my suggestions, that seems to contradict what you said in the first post: “past a certain CPU loading on my PC, my soundcard starts sending clicks to the speakers, and Audacity captures them”
Your earlier statement clearly suggests that the solution is to reduce CPU loading.
As Koz points out, there are several places that “data bottlenecks” can occur and cause these kinds of problems, and it would still be better to fix the cause of the problem than to try and deal with damage to the audio that results.
There are a load of suggestions for improving audio playback / recording performance in the “Tips” section of the Audacity wiki: http://audacityteam.org/wiki/index.php?title=Main_Page
Common causes of this kind of problem include:
Lack of disk space / disk fragmentation
Shortage of memory (real RAM memory - not virtual memory)
Anti-virus programs
Windows update
Viruses and spyware
Other programs and processes running in the background
USB devices are particularly susceptible to these types of problem, and there is a section on the wiki that specifically deals with USB.
Back to the “AND / XOR” question.
If dealing with the tracks as data streams, then the problem is the same as vocal isolation, but as you point out, in this special case we may be able to deal with it by bit-wise processing.
The original screen shot was not zoomed in enough to tell, but if as you suggest (and appears in the detail picture), the clicks are always samples that are greater (absolute value, disregarding sign) than the correct audio, then yes, you could correct the problem by bit-wise processing. To do this, you would write a Nyquist script; http://audacityteam.org/wiki/index.php?title=Nyquist_Basics:_The_Audacity_Nyquist_Prompt
Before you get too excited, there are a couple of practical problems/issues:
- Are the clicks always greater sample values than correct audio signal?
- Bit-wise processing can be very slow. The processing will probably be considerably slower than real time.
- Bit-wise processing is very memory heavy. If the processing does not all occur in RAM, then the speed will slow down even more, and some processes must use RAM.
Here is an example of Nyquist code that will do this. Note that the maximum length is set to 1000000 samples.
Also note that any clicks that have absolute values that are less than the sample value of the “correct” sound will be assumed to be correct and will be written to both channels.
(setq maxlen 1000000) ;; maximum length that can be processed (samples)
(setq samplerate (snd-srate (aref s 0))) ;; find sample rate
(setf common (make-array (snd-length (aref s 0) maxlen)));; initialise array
;; The complicated bit - this is the start of a "do" loop that
;; counts up from 0 until it runs out of samples
;; it also sets "left" to read samples sequentially
;; from the left audio channel, and "right" to read samples from the right channel
(do ((n 0 (1+ n)) (left (snd-fetch (aref s 0)) (setq left (snd-fetch (aref s 0))))(right (snd-fetch (aref s 1)) (setq right (snd-fetch (aref s 1)))))
;; Exit when we run out of samples (v is nil) and return the "common"array
((not left) common)
;; Start the execution part of the "do" loop
;; write the sample with the lowest absolute value to the array
(if (> (abs left)(abs right))(setf (aref common n) right)(setf (aref common n) left))
) ;; End of "do" loop
;; convert back to sound
(vector (snd-from-array 0 samplerate common) (snd-from-array 0 samplerate common))