Skip to content
Browse files

Update master

  • Loading branch information...
1 parent 270652d commit 27c2353d5797c36a33beb0d571f605edfe63331f @juliangruber committed Jun 10, 2012
Showing with 13 additions and 4 deletions.
  1. +13 −4 Oscillator-0.1.0.js
View
17 Oscillator-0.1.0.js
@@ -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.
@@ -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;
}
}
@@ -150,8 +161,6 @@ Oscillator.prototype.play = function() {
*/
Oscillator.prototype.pause = function() {
this.sustain = true;
- this.node.disconnect();
- this.playing = false;
}
/**

0 comments on commit 27c2353

Please sign in to comment.
Something went wrong with that request. Please try again.