Search code examples
javascripthtml5-audioweb-audio-api

filter audio using Web Audio Api


Is there a way to filter music so as to get a karaoke effect on an mp3 using Web Audio API? Thus i can administer a lowpass or highpass to filter out the voice and leave the drums or melody If not eliminating it


Solution

  • As @brybott said you can use: https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode for filtering the audio. I made a lib for Web Audio API which you could use to make this easier.

    CrotchetJS

    And a code example could be something like:

    <script src="Crotchet.js"></script>
    <script>
       //CREATE A FILTER WITH ATTRIBUTES TYPE, FREQUENCY, GAIN and Q
       var filter = CROTCHET.createFilter("HIGHPASS", 6000, 20, 1000);
       CROTCHET.loadSounds(["file1.mp3"], ["sound"], filter);
       CROTCHET.play("sound");
    </script>
    

    Hope it helps!