# FIR filter to delay signal [duplicate]

About filter design, mostly we want to control frequency amplitude response and the linearity of phase response. I wonder whether there are FIR filters specialized to delay signal?

For instance, let's say I want to process a multi-frequencies signal, delaying 1200Hz for offset = $$\frac{\pi}{8}$$ ($$f_s$$ = 44100) and leaving 500Hz unchanged.

Is such a FIR filter possible? How can I do it?

• my answer to the question above details a way of designing FIR filters to have a desired phase delay / group delay characteristic. – Marcus Müller Dec 4 '18 at 10:40
• What is your exact requriement regarding the amplitude response? Does it have to be totally flat or is some ripple allowed? – TheSlowGrowth Dec 4 '18 at 10:52
• @TheSlowGrowth Hi, ripple is allowed in amplitude response, which should be approximatly flat. What I want to control is the phase shift. Thanks. – Wei Lin Dec 4 '18 at 13:32

$$D(\omega)=|D(\omega)|e^{j\phi(\omega)}\tag{1}$$
where both the desired magnitude $$|D(\omega)|$$ as well as the desired phase $$\phi(\omega)$$ can be prescribed. A least squares approximation of $$(1)$$ by an FIR filter just involves the solution of a system of linear equations. I've written a Matlab/Octave function solving that problem: lslevin.m.
Note that it is important to choose the specification $$(1)$$ in such a way that it can be realistically achieved by an FIR filter of a given length $$N$$. E.g., the average delay implied by the desired phase $$\phi(\omega)$$ should be close to $$(N-1)/2$$, which is the delay of a linear phase FIR filter of length $$N$$.