velipso / sndfilter

Algorithms for sound filters, like reverb, dynamic range compression, lowpass, highpass, notch, etc
BSD Zero Clause License
445 stars 70 forks source link

Biquad filter is hard clipping the audio #21

Open hosembafer opened 2 years ago

hosembafer commented 2 years ago

I'm using sndfilter biquad filter as a chain of filters, i.e. combining lowshelf, peaking and highshelf filters.

In general, the equalizer should not over amplify the audio with the params I use.

I can see that you have ported Web Audio API biquad filter and the code is almost the same, but it results in completely different output.

eq-hard-clipping-diff
  1. Original
  2. GarageBand
  3. sndfilter

GarageBand is just an example, we will get almost the same result with other tools.

Could you please confirm whether this behavior is expected or maybe it's a known issue?

How to reproduce

Download drum-beat.wav

sndfilter drum-beat.wav filtered.wav lowshelf 250 1 20
sndfilter filtered.wav filtered.wav peaking 500 3 20

You can reproduce it only by using lowshelf or peaking, but it's more demonstrative when combining them too.

And also biquad filters affect only starting from around 1.3 seconds of the input audio. This is a separate issue BTW.