A program I'm writing produces a signal with a dc component that increases over time. I need some kind of post-process which can remove the dc content, without affecting the phase or magnitude of the interesting high-frequency content.
So far, I've tried running high-pass flat-passband IIR filters forwards then backwards over the signal. This works fine for the most part, but introduces large low-frequency oscillations at the end of the output.
I've also tried taking the FFT of the signal, and gradually reducing the magnitude of the lowest bins. The problem with this approach is that this is essentially circular convolution, so I get artefacts 'wrapping round' at the beginning and end of the signal.
Zero-padding the input doesn't seem to help in either of these approaches, because the signal goes from large-offset to zero in the space of a single sample. IIR filters are obviously going to have a hard time with this, and the FFT approach does too.
Some examples: This is the kind of raw output signal I'm generating.
This is the content I wish to extract (zoomed in at the beginning of the 'raw' signal).
Any advice would be appreciated. Thanks!