How to build a spectrometer - theory