That arrangement with the moved resistor is better. Another way of driving common-cathode LEDs is with PNP transitors (emitter to Vcc, collector to load, pull base low to switch transistor on).
The code looks ok, although you're drawing ~200mA from the USB port. If your computer is a laptop it might not like that. In any case check Vcc for glitches.
Is the preamp signal always disturbed when the LEDs are connected, or only when the signal amplitude is large?