How would this clean up the signal for noise?[Addition to post #17] You can do it in hardware. Either use a controlled invert-non-invert amplifier with the inversion selected by the output signal, or invert the return signal so that you have both inverted and non-inverted signals and switch between them using an analogue switch (CD4016).