jaakkopasanen / AutoEq

Automatic headphone equalization from frequency responses
MIT License
13.21k stars 2.47k forks source link

Linear Scale Smoothing #640

Closed jaakkopasanen closed 10 months ago

jaakkopasanen commented 1 year ago

Smoothing currently happens in dB scale and doing in in linear scale might be more correct.

jaakkopasanen commented 11 months ago

The boundary problem is real. Savitzky-Golay filter has a built-in extrapolation but normal moving average window doesn't. The alternative would be to shorten the window when approaching the boundary but this too would cause it's own set of problems. The extrapolation of Savitzky-Golay causes the extrapolated values to go negative in the linear scale and that of course cannot be transformed back to logarithmic scale.

jaakkopasanen commented 10 months ago

After having done some exploration, I'm confident in saying that what AutoEq does now is correct. The smoothing should produce a trend that follows the raw curve and Savitzky-Golay is an excellent filter for that, even near boundary. If data up to 40 kHz was available, it most likely would follow similar trend as is between 15 kHz and 20 kHz i.e. plunges even further down and good ol' moving average would then agree with Savitzky-Golay. Linear scale smoothing put more emphasis on lower frequencies when the trend is decreasing and so overestimates the level relative to log scale smoothing.

sav-gol_vs_moving_average_v2