Right now, the main difference between the two functions is in how the coefficients are computed: firwin multiplies the sinc function on the cutoff frequency bands, while firwin2 linearly interpolates the cutoff frequencies with a uniform mesh. If we can define a flag that switches between the two calculation methods, then we can preserve the functionality of both. I took a similar approach recently to switch between FIR and IIR filter coefficients when implementing gammatone filters for SciPy.
Parameter-wise, I think we can keep the gain, nfreqs, and antisymmetric parameters from firwin2, and remove the scale parameter from firwin. However, we might have to internally match the coefficients' order of magnitude inside the function, as firwin returns values in the 10e-4 range with scale set to True, while firwin2 returns values in the 10e-2 range.
Both functions have the nyquist frequency parameter marked as "deprecated" in the docstring, but they don't throw a warning in the code. Can we add this warning to the function?
- Shashaank