A digital pulse processor for high-rate high-resolution X and gamma-ray spectroscopy