Adaptive digital spectroscopy in programmable logic