{"id":13768554,"url":"https://github.com/mmckegg/adsr","last_synced_at":"2026-01-11T14:59:38.800Z","repository":{"id":13963754,"uuid":"16664217","full_name":"mmckegg/adsr","owner":"mmckegg","description":"UNMAINTAINED: Attack, decay, sustain, release envelope for automating Web Audio API AudioParams.","archived":true,"fork":false,"pushed_at":"2016-07-13T22:52:24.000Z","size":11,"stargazers_count":30,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T23:29:09.268Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmckegg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-09T10:11:50.000Z","updated_at":"2023-05-06T16:37:07.000Z","dependencies_parsed_at":"2022-08-02T19:01:25.350Z","dependency_job_id":null,"html_url":"https://github.com/mmckegg/adsr","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmckegg%2Fadsr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmckegg%2Fadsr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmckegg%2Fadsr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmckegg%2Fadsr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmckegg","download_url":"https://codeload.github.com/mmckegg/adsr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253324164,"owners_count":21890847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T16:01:22.804Z","updated_at":"2026-01-11T14:59:38.750Z","avatar_url":"https://github.com/mmckegg.png","language":"JavaScript","funding_links":[],"categories":["Sound editing"],"sub_categories":["ADSR envelopes"],"readme":"adsr\n===\n\nAttack, decay, sustain, release envelope for automating Web Audio API AudioParams.\n\n## Status: Unmaintained\n\nCheck out https://github.com/itsjoesullivan/envelope-generator, which is a much better implementation :)\n\n## Install\n\n```bash\n$ npm install adsr\n```\n\n## API\n\n```js\nvar ADSR = require('adsr')\n```\n\n### ADSR(audioContext)\n\nReturns an ADSR ModulatorNode instance.\n\n### node.attack (get/set)\n\nAttack time in seconds.\n\n### node.decay (get/set)\n\nDecay time in seconds.\n\n### node.sustain (get/set)\n\nDecimal representing what multiple of initial value to hold at in sustain portion of envelope.\n\n### node.release (get/set)\n\nRelease time in seconds.\n\n### node.value ([AudioParam](https://developer.mozilla.org/en-US/docs/Web/API/AudioParam))\n\nThe target value of the attack portion of envelope. Defaults to 1.\n\n### node.startValue (AudioParam)\n\nThe start value which will ramp to `node.value` over time specified by `node.attack`. Defaults to 0.\n\n### node.endValue (AudioParam)\n\nThe final value which will be ramped to over time specified by `node.release`. Defaults to 0.\n\n### node.connect(destinationAudioParam)\n\nConnect the modulator to the desired destination audio param.\n\n### node.disconnect()\n\nDisconnect from any target AudioParams and reset to `node.value`.\n\n### node.start(at)\n\nTrigger the attack-decay-sustain portion of the envelope at the specified time relative to audioContext.currentTime.\n\nThis can only be called once. Create additional instances of ADSR for multiple events.\n\n### node.stop(at, isTarget)\n\nSpecify the time to start the release portion of the envelope. Or if `isTarget === true`, the time the release portion should complete by.\n\nReturns the time that the release portion will complete by (this can be used to decide when to stop the source AudioNode)\n\n## Example\n\n```js\nvar audioContext = new AudioContext()\nvar oscillator = audioContext.createOscillator()\nvar gain = audioContext.createGain()\n\noscillator.connect(gain)\ngain.connect(audioContext.destination)\n\nvar envelopeModulator = ADSR(audioContext)\n\ngain.gain.value = 0 // set base value to 0 as modulators add to existing value\nenvelopeModulator.connect(gain.gain)\n\nenvelopeModulator.attack = 0.01 // seconds\nenvelopeModulator.decay = 0.4 // seconds\nenvelopeModulator.sustain = 0.6 // multiply gain.gain.value\nenvelopeModulator.release = 0.4 // seconds\n\nenvelopeModulator.value.value = 2 // value is an AudioParam\n\nenvelopeModulator.start(audioContext.currentTime)\noscillator.start(audioContext.currentTime)\n\nvar stopAt = envelopeModulator.stop(audioContext.currentTime + 1)\noscillator.stop(stopAt)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmckegg%2Fadsr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmckegg%2Fadsr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmckegg%2Fadsr/lists"}