-
Notifications
You must be signed in to change notification settings - Fork 1
Line & xLine Envelope
Kevin Lewis edited this page Feb 17, 2017
·
1 revision
Note: we need to include maxiExtras.js for this envelope to work.
This example will work with an oscillator or a sample. I am using an oscillator here, but the steps are exactly the same regardless.
Step 0 - Set up our basic oscillator
var audio = new maximJs.maxiAudio();
var osc = new maximJs.maxiOsc();
function setup() {
audio.play = playLoop;
audio.init();
}
function playLoop() {
this.output = osc.sinewave(440);
}
Step 1 - Set up our envelope object
var audio = new maximJs.maxiAudio(); var osc = new maximJs.maxiOsc(); var env = new maximEx.env();
Step 2 - Set up our envelope's settings
For a line envelope
function playLoop() { this.output = osc.sinewave(440) * env.line(0, 1, 3); }
For a xLine envelope
function playLoop() { this.output = osc.sinewave(440) * env.xLine(0, 1, 3); }
The first argument is the initial amplitude, and the second argument is the final amplitude, and the third argument is the time in which the transition between the two times will take place.
Step 3 - Trigger the envelope
function mousePressed() {
env.trigger();
}