Skip to content

Commit

Permalink
Update master
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Jun 10, 2012
1 parent 270652d commit 27c2353
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Oscillator-0.1.0.js
Expand Up @@ -24,8 +24,7 @@ function Oscillator(context, shape) {
this.attackC = 0;
this.attackM = 10000;
this.sustain = false;
this.sustainC = 0;
this.sustainM = 1000;
this.sustainC = this.sustainM = 1000;

// Define:
// workingBuffer for pre-amplified waveform.
Expand Down Expand Up @@ -122,6 +121,18 @@ Oscillator.prototype.process = function(e) {
this.attackC++;
} else {
this.attack = false;
this.attackC = 0;
}
}
if (this.sustain) {
if (this.sustainC > 0) {
this.workingBuffer[i] *= this.sustainC / this.sustainM;
this.sustainC--;
} else {
this.sustain = false;
this.node.disconnect();
this.playing = false;
this.sustainC = this.sustainM;
}
}

Expand Down Expand Up @@ -150,8 +161,6 @@ Oscillator.prototype.play = function() {
*/
Oscillator.prototype.pause = function() {
this.sustain = true;
this.node.disconnect();
this.playing = false;
}

/**
Expand Down

0 comments on commit 27c2353

Please sign in to comment.