Open galchinsky opened 8 years ago
All I can say from a few quick experiments is that the solution does indeed fix the issue of phase inversion, and that it does not appear to alter the sound, so the suggested fix from that thread is possibly correct.
The computation of odd-order high-pass filters of type Butterworth is broken. I have checked it with Matlab: If I run this filter with C++, for(int theOrder=1; theOrder<20; ++theOrder) { Dsp::SimpleFilter <Dsp::Butterworth::HighPass<20>, 1> myFilter; //1 channel, 20th order. Latter i can change the order. myFilter.setup(theOrder, fs, cuttOffFreq); myFilter.process(numSamples, mySignal); }
If I perform the same filtering with MATLAB: Filter algorithm: [z,p,k] = butter(theOrder, (2_cuttOffFreq / fs) , 'high'); [sos,gain] = zp2sos(z,p,k); f = dfilt.df2sos(sos); signalFiltered= gain_filter(f, mySignal);
If theOrder is even the resulted signals are the same with this library and with matlab. However, if theOrder is odd the filtered signals are different.
Hi, any news regarding this issue?
The computation of odd-order high-pass filters of type Butterworth is erroneous.
Certainly correct that this causes a phase inversion and the fix is correct. @anleu confirmed that now with a unit test using scipy output. Also makes total sense as there is complete symmetry between zero and pole. See my scribbles.
https://www.kvraudio.com/forum/viewtopic.php?f=33&t=386712 says that Biquad.cpp may contain an error and suggests the following patch:
But I don't undestand if this is correct solution or ad-hoc workaround which can break someone's code. If you know more, let me know.