Search code examples
htmlweb-audio-api

Is there way to apply EQ effects in HTML 5 web audio API?


I would like to know is there way we can apply EQ effects to audio in html 5 web audio. I wish to use 2 effects EQ Male and EQ female. I did some reasearch and found that these are nothing but some preset frequencies.

Edit:

Here is what I am looking for. enter image description here


Solution

  • Of course. Web Audio has lots of filtering capabilities. I did a standard low/mid/high EQ in my wubwubwub app, starting around line 189 of tracks.js (You may not want "this.", of course):

        this.low = audioCtx.createBiquadFilter();
        this.low.type = "lowshelf";
        this.low.frequency.value = 320.0;
        this.low.gain.value = 0.0;
        this.low.connect( /* your output node here - audioCtx.destination, maybe? */ );
    
        this.mid = audioCtx.createBiquadFilter();
        this.mid.type = "peaking";
        this.mid.frequency.value = 1000.0;
        this.mid.Q.value = 0.5;
        this.mid.gain.value = 0.0;
        this.mid.connect( this.low );
    
        this.high = audioCtx.createBiquadFilter();
        this.high.type = "highshelf";
        this.high.frequency.value = 3200.0;
        this.high.gain.value = 0.0;
        this.high.connect( this.mid );
    
        /* Now connect your input to this.high */