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

angular-vumeter

v1.0.0

Published

A customizable AngularJS directive representing a VU meter

Downloads

41

Readme

angular-vumeter - AngularJS directive representing a VU meter

npm version Bower version Build Status

VU meter demo preview

Quick links

Demo

Do you want to see directives in action? Check out the demo page!

Getting started

Install with NPM

$ npm install angular-vumeter

This will install angular-vumeter NPM package.

Install with Bower

$ bower install angular-vumeter

Adding dependency to your project

When you are done downloading all the dependencies and project files the only remaining part is to add dependencies on the angular-vumeter module:

angular.module('myModule', ['angular-vumeter']);

Including js and css

<script src="../node_modules/angular-vumeter/dist/angular-vumeter.min.js"></script>
<link href="../node_modules/angular-vumeter/dist/angular-vumeter.min.css" rel="stylesheet" type="text/css">

VU meter using the microphone input

By default the vumeter will be active as soon as the page is loaded and it will use microphone as default input. You can activate/deactivate VU meter defining the isActive attribute:

<vu-meter is-active="isActive"></vu-meter>

VU meter using an audio source

<vu-meter is-active="isActive" source-id="mySong"></vu-meter>
<audio id="mySong" controls="true">
    <source src="./assets/kevin_MacLeod-Slow_Burn.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
</audio>

Custom templates

By default the directive will show an svg template. This is inspired to the old analogic VU meter by TEAC corporation. You can download the original illustrator file of the svg template and customize it (vumeter.ai)

Using vuMeterConfig provider you can register a new template with you own logic:

vuMeterConfig.registerTemplate('myCustomTemplate', {
    path: 'path/to/html/or/svg/template',
    /**
    * Optional: This method is run only once. Function to find
    * elements before execution of the onDraw function.
    * It can be useful to find elements of the template that
    * need to be accessed multiple times during onDraw
    */
    getTemplateElements: function($element) {
        return [];
    },
    /**
    * Required: This method is run every 1024 audio samples.
    * Any manipolation of DOM to show audio visualization should be included here
    */
    onDraw: function($element, volume, templateElements) {}
}

This is the implementation for the default template:

{
    path: 'angular-vumeter/template/angular-vumeter.svg',
    getTemplateElements: function($element) {
        // let's find motion elements in svg knowing their types and ids
        function findElementInSVG(type, id) {
            var elements = $element.find(type);
            for (var i = 0; i < elements.length; i++) {
                var el = elements[i];
                if (el.id === id) {
                    return el;
                }
            }
        }
        // trigger is a g element
        var trigger = findElementInSVG('g', 'trigger');
        // peak is a ellipse element
        var peak = findElementInSVG('ellipse', 'peak');
        return [angular.element(trigger), angular.element(peak)];
    },
    onDraw: function($element, volume, templateElements) {
        // this is relative to the original system of coordinates of the template
        var rotationPivot = {
            x: 292,
            y: 331
        };

        // Let's get template elements calculated only once (not on every onDraw iteration)
        var trigger = templateElements[0];
        var led = templateElements[1];

        var minAngle = 65, maxAngle = 100;
        // Transform volume in a visual data
        var deg = Math.min((minAngle * volume) / 100, maxAngle);
        // Trigger rotation
        trigger.attr('transform', 'rotate(' + deg + ' ' + rotationPivot.x + ' ' + rotationPivot.y + ')');
        // Led blinking
        led.attr('fill', volume > 100 ? '#ea2b2c' : '#992B2C');
    }
}

You can create simpler or more complex audio visualization using html or svg templates

Support

Documentation

Check documentation here

Supported browsers

Directives from this repository are automatically tested with the following browsers:

  • Chrome
  • Firefox
  • Edge
  • Opera

angular-vumeter uses getUserMediaStream API (check its global support here)

Modern mobile browsers should work without problems.

Found a bug?

Please submit your issue here.