Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.24k stars 963 forks source link

[Question] `BiquadFilter.getFrequencyResponse` internals #1249

Closed tenub closed 3 weeks ago

tenub commented 1 month ago

I am curious what the purpose is of this calculation and why we are squaring.

If we look at something like weq8, they do things a little differently, as we can see here. Is this simply a difference in scaling preference for the curve? One would think that we could line up different filter frequencies with the response curve on a log scale but this does not seem to be the case with the current implementation of getFrequencyResponse. Is this a bug or intended?

tambien commented 3 weeks ago

They seem to be pretty comparable. It can be helpful to apply some log scaling to the visual output so that the higher frequencies are not as visually represented in the output. Seems like the main difference between the implementations is log 2 vs log 10. weq8 also does a smart thing of scaling the output to the nyquist frequency instead of just 20 to 20,000 like in Tone.js

I don't think they would visually line up with each other given some subtle differences in the calculation, but since this is intended for visual assistance and not anything else, i might consider both implementations equally correct.