/* This sketch shows how to use envelopes and oscillators. Envelopes are pre-defined amplitude distribution over time. The sound library provides an ASR envelope which stands for attach, sustain, release. The amplitude rises then sustains at the maximum level and decays slowly depending on pre defined time segments. .________ . --- . --- . --- A S R */ import processing.sound.*; TriOsc triOsc; Env env; // Times and levels for the ASR envelope float attackTime = 0.001; float sustainTime = 0.004; float sustainLevel = 0.3; float releaseTime = 0.4; // This is an octave in MIDI notes. int[] midiSequence = { 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72}; int duration = 200; // Set the note trigger int trigger = millis(); // An index to count up the notes int note=0; void setup() { size(640, 360); background(255); // Create triangle wave and start it triOsc = new TriOsc(this); //triOsc.play(); // Create the envelope env = new Env(this); } void draw() { // If the determined trigger moment in time matches up with the computer clock and we if the // sequence of notes hasn't been finished yet the next note gets played. if ((millis() > trigger) && (note