Skip to content

An audio analysis tool for real-time and choreographed visualizations.

License

Notifications You must be signed in to change notification settings

jonobr1/equalizer.js

Repository files navigation

equalizer.js

👂 An audio analysis tool for real-time and choreographed visualizations.

  1. Accepts all valid Web Audio nodes
  2. Accepts multiple nodes at once for complex scenes
  3. Configurable resolution and frame rate
  4. Dependency free
  5. Export/import analyzed data for precise playback
  6. Added classes for easy loading of audio files

Visit the hosted project page to try it out and to export or import JSON data for use with Equalizer.

Usage

npm install --save equalizer.js

Import in ES6 environment

import { Equalizer } from 'equalizer.js';

Load Script in HTML file:

This example creates an audio oscillator and visualizes it with an instance of Equalizer.

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <script src="https://cdn.jsdelivr.net/npm/equalizer.js/build/equalizer.js"></script>
    <script>

    var playing = false;
    var context = new AudioContext(); // From Web Audio API
    var equalizer = new Equalizer(context).appendTo(document.body);

    // Create audible sound with the Web Audio API
    var osc = context.createOscillator();

    osc.type = 'square';
    osc.frequency.setValueAtTime(440, context.currentTime);
    osc.connect(context.destination);
    osc.start();

    // Add the oscillator to the equalizer
    equalizer.add(osc);

    equalizer.domElement.addEventListener('click', resume, false);
    update();

    function resume() {
      if (!(/running/.test(context.state))) {
        context.resume();
      }
    }

    function update() {
      equalizer.update();
      requestAnimationFrame(update);
    }

    </script>
  </body>
</html>

⚠️ Due to the reliance on the Web Audio API, this project is not built for node.js use.

A free and open source tool by Jono Brandel