WebAudio / web-audio-api

The Web Audio API v1.0, developed by the W3C Audio WG
https://webaudio.github.io/web-audio-api/
Other
1.05k stars 168 forks source link

equal loudness filter #803

Closed kevinbarabash closed 8 years ago

kevinbarabash commented 8 years ago

I'm trying to correct for the fact that the human ear is less sensitive to low and high frequencies. I started by manually adjusting the gain on OscillatorNodes of different frequencies using data from https://plot.ly/~mrlyule/16/equal-loudness-contours-iso-226-2003/. This worked reasonably well for sine waves. The other wave types generated by the oscillator node are comprised of many different frequencies so I doubt this will work as well on them. Also, this approach won't work well for vibrato effects.

I was going to try to combine multiple BiquadFilterNodes together in an attempt to approximate the correct frequency response curve, but it seems like it's going to be difficult. I guess I can get the frequency response for each filter node and add them together to get the overall cover and adjust the settings until it matches the desired curve.

It would be nice if there was node that did this kind of equalization.

rtoy commented 8 years ago

I think filter design, which is what I think you're really asking for here, is outside the scope of this spec.

You should find a reference on filter design techniques to come up with an IIR or FIR filter that matches the curves you have. Then use the ConvolverNode, IIRFilterNode, or BiquadFitlerNode to create the desired responses.

kevinbarabash commented 8 years ago

I didn't realize that there was an IIRFilterNode. I'll have to play around with it and ConvolverNode. I guess I'll have to do some research to see how convolution can be used to build filters. I guess if all of these building blocks can be used to build such a filter than it probably doesn't belong in the spec. Thanks for pointing me in the right direction.

rtoy commented 8 years ago

The IIRFilterNode is relatively new. I think only Chrome has it right now, but I expect other browsers to have it pretty quickly.

As for a ConvolverNode for filtering, you use an FIR design method to get the FIR filter coefficients for your filter. This is the impulse response you want to use for the ConvolverNode. But be sure to turn off the normalization of the ConvolverNode. If you don't the output will be scaled in some (constant) way that you probably don't want.

On Tue, May 10, 2016 at 1:45 PM, Kevin Barabash notifications@github.com wrote:

I didn't realize that there was an IIRFilterNode. I'll have to play around with it and ConvolverNode. I guess I'll have to do some research to see how convolution can be used to build filters. I guess if all of these building blocks can be used to build such a filter than it probably doesn't belong in the spec. Thanks for pointing me in the right direction.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/WebAudio/web-audio-api/issues/803#issuecomment-218285641

Ray