We show that a compact representation of either a semisimple Lie group or a totally disconnected group has a filtration with irreducible subquotients of finite multiplicity. In the Lie group case we show the stronger assertion, that it has an orthogonal decomposition into summands of finite lengths. This generalises and simplifies a number of more special spectral theorems in Deitmar and Monheim (Math Z 284(3–4):1199–1210, 2016, https://doi.org/10.1007/s00209-016-1695-9), Müller (Int Math Res Not 9(2):2068–2109, 2011), Venkov (in: Proceedings of the Steklov Institute of Mathematics, no. 4(153), ix+163 pp. (1983), 1982). We apply it to the case of cusp forms, thus settling the spectral theory for the space of non-unitary twisted cusp forms. We finally show that the space of cusp forms is complemented by the space of Eisenstein series.