Linear phase FIR filter design is a real-valued approximation problem because only the real-valued amplitude function needs to be approximated. If magnitude and phase are prescribed simultaneously, the resulting approximation problem is complex-valued, because we try to approximate the complex-valued frequency response.
It depends on the chosen optimality criterion whether the complex approximation problem (i.e., prescribed magnitude and phase) is fundamentally more difficult than the real-valued problem (linear phase design). In most cases it is. However, for the least squared error criterion - which I believe is a very practical and useful one - the complex approximation problem is as straightforward to solve as the real approximation problem. Both problems are linear in the filter coefficients (obviously for FIR filters only), and, consequently, the design problem is solved by solving a system of linear equations.
As far as I know there is no function in Matlab/Octave for the least squares design of FIR filters with prescribed magnitude and phase responses, but it just takes a few lines of code to implement it. I wrote the Matlab/Octave function cfirls.m that designs non-linear phase FIR filters with possibly complex-valued coefficients. The function could easily be modified to only allow symmetrical frequency responses to force the resulting filter to be real-valued. Note, however, that even with the function in its current form, the optimal filter for a symmetrical frequency domain specification will be real-valued, up to numerical accuracy.
For other optimality criteria, such as the Chebyshev criterion, the complex approximation problem for non-linear phase filter design becomes more, well, complex. In the linear phase case we have the alternation theorem that is used in the Remez exchange algorithm. In general, nothing similar exists in the complex case. The complex Chebyshev design problem can be approximately solved by solving a linear programming problem. This approach was first proposed by Chen and Parks: Design of FIR filters in the complex domain. This method is very slow compared to the Remez algorithm, but it is nevertheless reliable because methods for solving linear programs are very mature.
It should be noted that when prescribing magnitude and phase responses of a causal filter, we don't need to worry about the Hilbert transform relationship between them, because in practice there are almost always transition bands ("don't care") bands where neither magnitude nor phase responses are specified. Moreover, in stopbands, the phase is unspecified. This gives room for the resulting magnitude and phase responses to match (as Hilbert transform pairs) in any case. Of course, there are limits to what can be achieved with a causal FIR filter, but for a least squares design the result will always be optimal (and unique), even though the resulting filter may not be useful because of a large deviation from the specified response.
EXAMPLE: Using the function cfirls.m
, I designed five $51$-taps lowpass filters with the same magnitude specification but with different desired constant group delays in the passband. In the first case I specified the group delay to be $25$ samples, which corresponds to a linear phase filter. The optimal filter is indeed a symmetrical filter, i.e., a filter with exactly linear phase. The passband group delays of the other four filters were specified to be $20$, $15$, $10$, and $5$ samples respectively. Of course, for very low delays (compared to the filter length), the design goals are harder to meet and the approximation error becomes larger. But for some modest delay reduction the results are still useful. The figure below shows the design results:
@<TAB>
because I don't get notified of the reply otherwise (now, I saw this appearing in the hot list so I thought I'd check on it, again). $\endgroup$