  M\"ossbauer nuclei feature exceptionally narrow resonances at hard x-ray
energies, which render them ideal probes for structure and dynamics in
condensed-matter systems, and a promising platform for x-ray quantum optics and
fundamental tests. However, a direct spectroscopy at modern x-ray sources such
as synchrotrons or x-ray free electron lasers is challenging, because of the
broad spectral bandwidth of the delivered x-ray pulses, and because of a
limited spectral resolution offered by x-ray optics and detectors. To overcome
these challenges, here, we propose a spectroscopy technique based on a
spectrally narrow reference absorber that is rapidly oscillating along the
propagation direction of the x-ray light. The motion induces sidebands to the
response of the absorber, which we scan across the spectrum of the unknown
target to gain spectral information. The oscillation further introduces a
dependence of the detected light on the motional phase at the time of x-ray
excitation as an additional controllable degree of freedom. We show how a
Fourier analysis with respect to this phase enables one to selectively extract
parts of the recorded intensity after the actual experiment, throughout the
data analysis. This allows one to improve the spectral recovery by removing
unwanted signal contributions. Our method is capable of gaining spectral
information from the entire measured intensity, and not only from the intensity
at late times after the excitation, such that a significantly higher part of
the signal photons can be used. Furthermore, it not only enables one to measure
the amplitude of the spectral response, but also its phase.
