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

nvelope

v0.12.0

Published

enveloping for audio and time domain DSP

Downloads

15

Readme

nvelope

A general purpose module for audio envelopes, or amplitude modulation.

An audio envelope is amplitude modulation. Ampltiude modulation is is the multiplication of waves. It is the "timesing" over time.

With this module you can construct arbitrarily long, multipart amplitude modulations. You must set the duration of each part, and you can repeat loopo over all or part by manipulating time.

nvelope returns a constructor, which returns the envelope. The envelope take a single argument, time.

It is meant to be used with a visual interface for drawing curves, which I am building for the html fives.

example

var  nvelope = require('nvelope');
var amod = nvelope(curves, durations)

drumvelope is a now a function which accepts a time value and will return an amplitude value. time should be between zero and the sum total of all durations. Any values outside of that will return 0. Then:

var DSPfunction = function(time){
	return Math.sin(time * Math.PI * 2 * 440) * amod(time)
}

curves and durations

curves is an array of arrays, or rayray, each of which is an array of arrays, or rayray, each of which is a set of controlPoints for a quadrtic curve.

durations is an array of values that correspond to an index in the controlPoints. Values are the duration in seconds for that curve.

NOTE: the module determines the total length of your envelope by adding together the durations. This is important, because the envelope will return zero for any time value falling outside of [0, totalDuration]. That is, the envelope requires a relative time value. This makes them loopable, by doing this:

var DSP = function(time){
	return sineWave(440) * amod(time % totalDuration)
} 

####control points, durations

var controlPoits =  [ 
                      [ 
                        [0,0], [0,4], [1,2] 
                      ], 
                      [ 
                        [1,2], [0,0], [1,0] 
                      ] 
                    ]

var durations = [.2, 1.8] // in seconds

That envelope has two sets of control points, an attack and a decay. The array of durations corresponds to an index each of the curves / controlPoints. In this one, the attack is very short, at .2 seconds, decay long. You may be able to visualize the two curves represented by the sets of control points, which in this case, have 3 points each. Note: a set of control points can have any number, n > 1, of control points. You can construct one long envelope with a single set of control points.

You probably want each set to normalize the x values to the [0,1] range. But I don't really understand how this works. The algorithm is point specific, which works at audio samplerates.

npm install nvelope