1

I'm looking to implement a 3 Band EQ mimicking a standard DJ Mixer.

Unfortunately I'm not having much luck. I know it involves creating BiquadFilter nodes and connecting them to a gain node. Unfortunately I'm not getting anywhere near the desired results.

The only success I'm having so far is just the gainNode to control the volume of the track.

Any assistance would be greatly appreciated.

Thanks, Stan

stan229
  • 2,592
  • 19
  • 23
  • I had a very similar question here: [Creating a 10-Band Equalizer Using Web Audio API](http://stackoverflow.com/questions/12738056/creating-a-10-band-equalizer-using-web-audio-api) – idbehold Dec 10 '12 at 03:20
  • it looks like the answer didn't really talk about defining the filters and hooking them up with a gain node. – stan229 Dec 10 '12 at 03:38

1 Answers1

6

I'll go ahead and elaborate on my answer on idbehold's question:

I would say that you probably want to use filters with type 5 (peaking), which lets all frequencies through and only amplifies/reduce at the frequency at which you've set the respective filter.frequency.value. That lets you connect the filters in series so you don't need separate audio paths. You could also consider using a low-shelf filter as the first filter, and a hi-shelf filter as the third, which is rather common in 3-band equalizers.

If you go with the peaking filters in series, you don't need a separate gain node for each frequency, you just set the filter.gain.value for the specific filters.

The code would look something like this:

var lowshelf = context.createBiquadFilter(),
    mid = context.createBiquadFilter(),
    highshelf = context.createBiquadFilter();

 //set the filter types (you could set all to 5, for a different result, feel free to experiment)
 lowshelf.type = 3;
 mid.type = 5;
 highshelf.type = 4;

 //connect 'em in order
 yourInput.connect(lowshelf);
 lowshelf.connect(mid);
 mid.connect(highshelf);
 highshelf.connect(yourOutput);

You can then adjust each band with their respective Q, frequency and gain values (check https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#BiquadFilterNode to see which params works with which filter type), for example:

 lowshelf.gain.value = 0.6;
 lowshelf.frequency.value = 300;

EDIT:

To add a separate gain, just do

  var gainNode = context.createGainNode();

and then either do

gainNode.connect(lowshelf); //pre EQ

or

highshelf.connect(gainNode); //post EQ

depending on whether you want it post or pre the EQ. You control the gain by doing

gainNode.gain.value = 0.6;
Oskar Eriksson
  • 2,591
  • 18
  • 32
  • How about integrating a gain node with that, to control the volume of the sound. I'm working on simulating a DJ audio mixer. Thanks again! – stan229 Dec 10 '12 at 16:21
  • 1
    I've added that to the answer. :) Feel free to "accept" the answer if it helped you! – Oskar Eriksson Dec 10 '12 at 16:54
  • I tried doing the postEQ way but then when the gainNode gain value is 1.0 then the filters don't work. When I bring it down to say .95 I can modify the filter's individual gain volume to hear the output change. With the preEQ way, I'm not hearing anything from the filters. https://gist.github.com/4254053 – stan229 Dec 10 '12 at 22:49
  • hi @OskarEriksson, would you mind to take a look at this question? http://avp.stackexchange.com/questions/6949/typical-frequency-bands-for-mixer-low-mid-and-high-gains What parameters would you advise to put in the lowshelf / peak / highshelf BiquadFilters in order to replicate the feel of a "typical" mixer? (currently my lowshelf freq is 80, mid/peak is 1000 and hi-shelf is 8000. I'm still undecided on the Q factor for the mid / peak) – janesconference Jan 25 '13 at 17:08