Skip to content
jshanley edited this page Nov 4, 2014 · 3 revisions

Helper Functions

# blip.mtof(number)

Converts the specified number, which is a MIDI note number, to a frequency in Hz.

ADSR Envelope

# blip.envelope()

Creates and returns a new envelope instance.

A blip envelope inherits the prototype of a BlipNode, which means it can be connected to and from other blip nodes using the .connect method.

# envelope.attack([time])

If time is specified, sets the length (in seconds) of the attack phase of the envelope.

If time is not specified, returns the current attack value.

# envelope.decay([time])

If time is specified, sets the length (in seconds) of the decay phase of the envelope.

If time is not specified, returns the current decay value.

# envelope.sustain([value])

If value is specified, sets the relative volume for the sustain phase of the envelope. This assumes that the peak volume at the top of the attack phase is 1.0

If value is not specified, returns the current sustain value (default is 0.8).

# envelope.release([time])

If time is specified, sets the length (in seconds) of the release phase of the envelope.

If time is not specified, returns the current release value.

# envelope.noteOn([time])

Triggers the attack phase of the envelope. If time is specified, sets the time at which the attack will be triggered, otherwise it is triggered immediately. This causes the envelope to proceed through the attack and decay phases, and remain in the sustain phase until envelope.noteOff() is called.

# envelope.noteOff([time])

Triggers the release phase of the envelope. If time is specified, sets the time at which the release will be triggered, otherwise it is triggered immediately.

# envelope.play(time, duration)

Triggers the envelope sequence at the specified time. The envelope will proceed through the attack and decay phases, and sustain until the specified duration after the given time, at which point the release phase is triggered. This is just a shortcut for calling envelope.noteOn(t) and envelope.noteOff(t + d) where t is time and d is duration

Clone this wiki locally