npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

canvas-equalizer

v0.2.0

Published

A JavaScript + HTML5 Canvas + Web Audio API sound equalizer.

Downloads

13

Readme

canvas-equalizer

Version Dependencies status Dev dependencies status

This package allows you to graphically edit an equalizer filter and apply it to songs in real time. You can also apply the filter to an entire song and download a WAVE file with the filtered song. Check out the live sample on the project's website: https://opensource.kantorad.io/canvas-equalizer/

This is a fork of Carlos Rafael Gimenes das Neves's port of his own old C++ graphic equalizer to Web technologies, with a few important differences:

  • Analyser files have been moved to the demo;
  • The demo is on its own branch;
  • Everything but the demo has been ported to TypeScript;
  • Styles ported to SASS;
  • Refactored mouse and touch event handling to use Pointer Events when available;
  • Responsive UI (including DPI awareness);
  • Built using Webpack;
  • Code linting;
  • Localization and internationalization;
  • RTL support;
  • Can be installed via NPM or Yarn.

Installation

Install it with one of the following commands:

$ yarn add canvas-equalizer
# or
$ npm install --save canvas-equalizer

Then, you need to import the module:

import CanvasEqualizer from 'canvas-equalizer'; // ES6, TypeScript
var CanvasEqualizer = require('canvas-equalizer'); // CommonJS

Or, if you've installed it via Bower (will add CanvasEqualizer to the global scope):

<script src="bower_components/canvas-equalizer/dist/CanvasEqualizer.js"></script>

Last, but not least: the CanvasEqualizer.css stylesheet includes styles for the UI, including its "status bar".

Usage

const equalizer = new CanvasEqualizer(
    // the FFT size; must be a power of 2 not less than 8 (recommended: 2048)
    filterLength,

    // an AudioContext object
    audioContext, 

    // additional, optional parameters with respective defaults
    {
        // whether to update the filter as the user drags the UI around;
        // `false` means the filter is updated only when dragging is done
        updateFilterOnDrag: false,

        // the prefix for all CSS classes used by the UI
        classNamespace: 'GE',

        // the UI language
        language: 'en'

        filterOptions: {
            // how many points the curves will actually have in the UI
            visibleBinCount: 512,
            
            // when needed, the height of a point in the curve will be
            // converted from the dB range (+40 dB to -40 dB) to an integer
            // range (zero to this value); must be an odd number
            validYRangeHeight: 255
        }
    }
);

// create and attach, e.g., a MediaElementSourceNode:
const audio = new Audio('https://example.com/sound.mp3');
const source = audioContext.createMediaElementSource(audio);
source.connect(equalizer.convolver);
equalizer.convolver.connect(audioContext.destination);

// expose the UI:
equalizer.createControl(document.getElementById('myelement'));

// change the UI language (`src/locales` contains the translation strings):
equalizer.loadLocale('pt-BR', {/* object containing translation strings */});
equalizer.language = 'pt-BR';

// reset the curves:
equalizer.reset();

// destroy the UI:
equalizer.destroyControl();

// more properties:
equalizer.filterLength;
equalizer.sampleRate;
equalizer.audioContext;
equalizer.visibleFrequencies; // read-only

The code in the demo folder can be used as a demo on how to load and generate files during runtime (using the File API and the Web Worker API) in client-side JavaScript.

Compatibility

This project uses the Web Audio API and requires a compliant browser to run properly. In Firefox 23 and 24, Web Audio API must be enabled using about:config.

If running the demo locally, Chrome must be started with the command-line option --allow-file-access-from-files, otherwise you will not be able to load any files!

License

This project is licensed under the terms of the FreeBSD License. See LICENSE.md for more details.