Spectral theory of dynamical systems as diffraction theory of sampling functions