2
votes

I'm learning to use the web audio api to synthesize and process sound. I see there's a BiquadFilterNode class I can use, but it only allows to specify one of the filter types defined ("lowpass", "highpass", "bandpass", "lowshelf", "highshelf", "peaking", "notch", "allpass") and control it through the meta parameters of such filters: Q, gain and center-frequency.

Is there a way to specify the actual coefficients of the digital filter? In other words, for a filter of the form:

       b_0 + b_1*z^(-1) + b_2*z^(-2)
H(z) = -----------------------------
       1 + a_1*z^(-1) + a_2*z^(-2)

can I somehow directly specify the values of b_0, b_1, b_2, a_1, a_2?

I ask because although the predefined filter types are very handy, they don't necessarily cover all the use cases. By specifying the coefficients it would be possible to implement first-order filters, parametric sections, etc.

2
This seems not to be possible. But here is written Multiple BiquadFilterNode filters can be combined to form more complex filters. Perhaps that helps..otherwise you have to implement the filter by your own. - bitWorking
Thanks for your suggestions @redreggae. I know I could implement filters directly in JavaScript (using ScriptProcessorNode), but this is very inefficient and I'm pretty sure that everything needed is already implemented at a low level in the BiquadFilterNode. Is just a matter of exposing the coefficients through the API. - jorgeh

2 Answers

0
votes

It's not currently possible, but is a simple API to add.

At the least, it's clear we need to add support for 1st-order filters.

0
votes

This isn't possible. There's a proposal for an entirely separate DSP API in the WG, but it's not completely baked yet.