
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Attack, decay, sustain, release envelope for automating Web Audio API AudioParams.
Attack, decay, sustain, release envelope for automating Web Audio API AudioParams.
$ npm install adsr
var ADSR = require('adsr')
Returns an ADSR ModulatorNode instance.
Attack time in seconds.
Decay time in seconds.
Decimal representing what multiple of initial value to hold at in sustain portion of envelope.
Release time in seconds.
The target value of the attack portion of envelope. Defaults to 1.
The start value which will ramp to node.value
over time specified by node.attack
. Defaults to 0.
The final value which will be ramped to over time specified by node.release
. Defaults to 0.
Connect the modulator to the desired destination audio param.
Disconnect from any target AudioParams and reset to node.value
.
Trigger the attack-decay-sustain portion of the envelope at the specified time relative to audioContext.currentTime.
This can only be called once. Create additional instances of ADSR for multiple events.
Specify the time to start the release portion of the envelope. Or if isTarget === true
, the time the release portion should complete by.
Returns the time that the release portion will complete by (this can be used to decide when to stop the source AudioNode)
var audioContext = new AudioContext()
var oscillator = audioContext.createOscillator()
var gain = audioContext.createGain()
oscillator.connect(gain)
gain.connect(audioContext.destination)
var envelopeModulator = ADSR(audioContext)
gain.gain.value = 0 // set base value to 0 as modulators add to existing value
envelopeModulator.connect(gain.gain)
envelopeModulator.attack = 0.01 // seconds
envelopeModulator.decay = 0.4 // seconds
envelopeModulator.sustain = 0.6 // multiply gain.gain.value
envelopeModulator.release = 0.4 // seconds
envelopeModulator.value.value = 2 // value is an AudioParam
envelopeModulator.start(audioContext.currentTime)
oscillator.start(audioContext.currentTime)
var stopAt = envelopeModulator.stop(audioContext.currentTime + 1)
oscillator.stop(stopAt)
FAQs
Attack, decay, sustain, release envelope for automating Web Audio API AudioParams.
The npm package adsr receives a total of 0 weekly downloads. As such, adsr popularity was classified as not popular.
We found that adsr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.