1.1.0 • Published 5 years ago

a-d-s-r v1.1.0

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

a-d-s-r

given a gainNode, does the ADSR dance

NPM Build Status

API

adsr(gainNode, when/time/ac.currentTime(probably), adsrObject:{attack, decay, sustain, release, peak, mid, end})

EXAMPLE

var AudioContext = AudioContext || webkitAudioContext
var ac = new AudioContext()
var gain = ac.createGain()

// other stuff, make an oscillator, idk, do u

adsr(gain, ac.currentTime, {attack: 0.25, decay: 0.1, sustain: 0.2, release: 0.05, peak: 0.7, mid: 0.5, end: 0.000001})

WOW, COOL!

starting at the passed time (2nd arg) 
the adsr function will take the gain of the gain node 
from whatever it is at to the peak volume in attack time,
then down to the mid in decay time,
then chill at the mid for sustain time,
then go down to 0 after release time.