Various instruments produce data consisting of a series of more or less isolated peaks, superimposed on a drifting baseline. The positions and the heights of the peaks are of interest and the baseline is a nuisance. We model a smooth baseline by weighted regression on P-splines, a combination of B-splines and a discrete penalty to tune smoothness. The weights are computed from a mixture model with two component distributions, relative to the baseline, one for noise, the other for the peaks. The algorithm is fast and it shows excellent performance on simulated and experimental data.