Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a 10-Band Equalizer Using Web Audio API

I'm trying to wrap my head around using the Web Audio API to recreate something like
Winamp's 10-band equalizer.

Winamp's 10-band equalizer
(source: head-fi.org)

From what I can gather, I have to create 10 Biquad Filters, set their type to 2 (for a Bandpass filter) and set their frequency to [60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000] respectively. Once I have done that (and here's where I'm getting a little confused) I would then create a separate Gain Node for each frequency "band" and bind its value to a slider.

<input id="someFreqBand" type="range" min="-12" max="12" step="0.1" value="0" onchange="slide()"/>

Assuming all of that is correct, then the only remaining step is to connect all 10 gain nodes to the Audio Context destination (which I imagine will take all 10 frequency "bands" and mix/sync them back together). Is this the right way to go about creating a Web Audio 10-band equalizer?

The major thing I'm confused about is how I go about "connecting" the source to the 10 frequency band filters (+ associated gain node) since all the nodes only have a single input or output (including the destination).

like image 719
idbehold Avatar asked Oct 05 '12 00:10

idbehold


People also ask

What is a 10 band equalizer?

The 10 band equalizer element allows to change the gain of 10 equally distributed frequency bands between 30 Hz and 15 kHz.

How many bands can be on a graphic equalizer?

Graphic EQs typically divide sound into six or 31 bands of frequency, with a slider controlling each band. The number of filters used depends on the EQ.


1 Answers

By connecting every filter with the destination you are creating 5 paths (routes) so you will hear quintupling amplification of the source sound. It's not the correct way. You have to connect each filter in one line.

source.connect(filter1);
filter1.connect(filter2);
filter2.connect(filter3);
filter3.connect(filter4);
filter4.connect(filter5);
filter5.connect(context.destination);
like image 66
Łukasz Jagodziński Avatar answered Sep 19 '22 16:09

Łukasz Jagodziński