general computation of spectra function