All Projects → velipso → adsrnode

velipso / adsrnode

Licence: MIT license
Advanced ADSR envelope node for WebAudio

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to adsrnode

fastidious-envelope-generator
Envelope generator (aka ADSR) for the Web Audio API that aims to be free of artifacts and handle edge cases well
Stars: ✭ 56 (+69.7%)
Mutual labels:  webaudio, adsr
Tinysynth
A drums looper made with React and the WebAudio API
Stars: ✭ 238 (+621.21%)
Mutual labels:  webaudio
Cordova Plugin Audioinput
This iOS/Android Cordova/PhoneGap plugin enables audio capture from the device microphone, by in near real-time forwarding audio to the web layer of your application. A typical usage scenario for this plugin would be to use the captured audio as source for a web audio node chain, where it then can be analyzed, manipulated and/or played.
Stars: ✭ 137 (+315.15%)
Mutual labels:  webaudio
Signal
A friendly music sequencer built with web technology
Stars: ✭ 166 (+403.03%)
Mutual labels:  webaudio
Nes Rust
NES emulator written in Rust + WASM
Stars: ✭ 141 (+327.27%)
Mutual labels:  webaudio
Audioworklet Polyfill
🔊 Polyfill AudioWorklet using the legacy ScriptProcessor API.
Stars: ✭ 179 (+442.42%)
Mutual labels:  webaudio
Nes Js
JavaScript NES(Famicom) emulator
Stars: ✭ 131 (+296.97%)
Mutual labels:  webaudio
webaudio-synth
WebAudio Polyphonic Synthesizer
Stars: ✭ 83 (+151.52%)
Mutual labels:  webaudio
Beact
🎸🎨 DJ and VJ all by yourself in seconds !
Stars: ✭ 223 (+575.76%)
Mutual labels:  webaudio
Dynamicaudio.js
An interface for the Web Audio API with a Flash shim for older browsers
Stars: ✭ 164 (+396.97%)
Mutual labels:  webaudio
Twigl
twigl.app is an online editor for One tweet shader, with gif generator and sound shader, and broadcast live coding.
Stars: ✭ 145 (+339.39%)
Mutual labels:  webaudio
Alien.js
Future web pattern
Stars: ✭ 141 (+327.27%)
Mutual labels:  webaudio
Pixi Sound
WebAudio API playback library, with filters. Modern audio playback for modern browsers.
Stars: ✭ 201 (+509.09%)
Mutual labels:  webaudio
Tuner
Online tuner based on web audio api
Stars: ✭ 140 (+324.24%)
Mutual labels:  webaudio
Videojs Wavesurfer
video.js plugin that adds a navigable waveform for audio and video files
Stars: ✭ 242 (+633.33%)
Mutual labels:  webaudio
Quiet Js
Transmit data with sound using Web Audio -- Javascript binding for libquiet
Stars: ✭ 1,725 (+5127.27%)
Mutual labels:  webaudio
Guitar Tuner
Browser-based guitar tuner
Stars: ✭ 146 (+342.42%)
Mutual labels:  webaudio
Black
World's fastest HTML5 2D game engine   🛸
Stars: ✭ 174 (+427.27%)
Mutual labels:  webaudio
elm-audio-graph
Declarative Web Audio in Elm
Stars: ✭ 14 (-57.58%)
Mutual labels:  webaudio
Three.js
JavaScript 3D Library.
Stars: ✭ 78,237 (+236981.82%)
Mutual labels:  webaudio

ADSRNode

ADSRNode is a single JavaScript function that creates an ADSR envelope for use in WebAudio.

Usage

ADSRNode(audioCtx, opts)

// create the Audio Context
var ctx = new AudioContext();

// simple ADSR envelope
var envelope = ADSRNode(ctx, {
  attack:  0.1, // seconds until hitting 1.0
  decay:   0.2, // seconds until hitting sustain value
  sustain: 0.5, // sustain value
  release: 0.3  // seconds until returning back to 0.0
});

// advanced ADSR envelope
var envelope = ADSRNode(ctx, {
  base:         5.0, // starting/ending value (default: 0)
  attack:       0.2, // seconds until hitting peak value (default: 0)
  attackCurve:  0.0, // amount of curve for attack (default: 0)
  peak:         9.0, // peak value (default: 1)
  hold:         0.3, // seconds to hold at the peak value (default: 0)
  decay:        0.4, // seconds until hitting sustain value (default: 0)
  decayCurve:   5.0, // amount of curve for decay (default: 0)
  sustain:      3.0, // sustain value (required)
  release:      0.5, // seconds until returning back to base value (default: 0)
  releaseCurve: 1.0  // amount of curve for release (default: 0)
});

The returned envelope object is a ConstantSourceNode.

It can be connected to other nodes using the normal envelope.connect(...) and envelope.disconnect(...) functions.

It must be started with envelope.start(), to begin outputting the base value. It can be stopped with envelope.stop().

The following methods/properties are added to the object:

envelope.trigger([when])

Trigger the envelope.

The when parameter is optional. It's the time, in seconds, at which the envelope should trigger. It is the same time measurement as AudioContext.currentTime, just like many other functions that take timed events. I.e., to trigger in two seconds, you would do: envelope.trigger(ctx.currentTime + 2). If omitted, it will trigger immediately.

envelope.release([when])

Release a triggered envelope.

The when parameter behaves just like envelope.trigger.

envelope.reset()

Reset an envelope immediately (i.e., output base value and wait for a trigger).

envelope.update(opts)

Update the values of the ADSR curve. All keys are optional. For example, to just update the peak, use envelope.update({ peak: 2 }).

Updating the envelope will also reset it.

envelope.baseTime

This value is set after an envelope.release(...) to provide the exact moment (in absolute seconds) that the envelope will return to the base value.

Triggering and Releasing

Special care has been taken to ensure the envelope correctly responds to triggering and releasing while still outputting a partial envelope.

For example, if a trigger happens in the middle of the release phase, the attack will pick up where the release left off -- as it should. Or if a release happens during the attack phase, it will correctly apply the release curve where the attack left off, etc.

The only requirement from users of the library is to ensure calls to trigger and release happen in chronological order.

For example, the following will fail, because it attempts to insert a trigger before a future trigger:

// this FAILS
envelope.trigger(8); // schedule trigger at 8 second mark
envelope.trigger(5); // schedule trigger at 5 second mark (error!)

This is easily fixed by simply ordering the calls:

// valid
envelope.trigger(5);
envelope.trigger(8);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].