Skip to content

Commit

Permalink
register objects with soundArray so they can be disposed when sketch …
Browse files Browse the repository at this point in the history
…is removed
  • Loading branch information
therewasaguy committed Jan 18, 2016
1 parent 676dbaa commit ca1e8e8
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 5 deletions.
11 changes: 10 additions & 1 deletion lib/p5.sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,8 @@ amplitude = function () {
this.output.connect(this.audiocontext.destination);
// connect to p5sound master output by default, unless set by input()
p5sound.meter.connect(this.processor);
// add this p5.SoundFile to the soundArray
p5sound.soundArray.push(this);
};
/**
* Connects to the p5sound instance (master output) by default.
Expand Down Expand Up @@ -2547,6 +2549,8 @@ fft = function () {
5200,
14000
];
// add this p5.SoundFile to the soundArray
p5sound.soundArray.push(this);
};
/**
* Set the input source for the FFT analysis. If no source is
Expand Down Expand Up @@ -3729,7 +3733,6 @@ oscillator = function () {
this.output.gain.linearRampToValueAtTime(currentVol, now + tFromNow);
this.output.gain.linearRampToValueAtTime(vol, now + tFromNow + rampTime);
} else if (vol) {
console.log(vol);
vol.connect(self.output.gain);
} else {
// return the Gain Node
Expand Down Expand Up @@ -5188,6 +5191,8 @@ filter = function () {
if (type) {
this.setType(type);
}
// add to the soundArray
p5sound.soundArray.push(this);
};
/**
* Filter an audio signal according to a set
Expand Down Expand Up @@ -5465,6 +5470,8 @@ delay = function () {
// default routing
this.setType(0);
this._maxDelay = this.leftDelay.delayTime.maxValue;
// add this p5.SoundFile to the soundArray
p5sound.soundArray.push(this);
};
/**
* Add delay to an audio signal according to a set
Expand Down Expand Up @@ -7394,6 +7401,8 @@ gain = function () {
// otherwise, Safari distorts
this.input.gain.value = 0.5;
this.input.connect(this.output);
// add to the soundArray
p5sound.soundArray.push(this);
};
/**
* Connect a source to the gain node.
Expand Down
6 changes: 3 additions & 3 deletions lib/p5.sound.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/amplitude.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ define(function (require) {
// connect to p5sound master output by default, unless set by input()
p5sound.meter.connect(this.processor);

// add this p5.SoundFile to the soundArray
p5sound.soundArray.push(this);
};

/**
Expand Down
3 changes: 3 additions & 0 deletions src/delay.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ define(function (require) {
this.setType(0);

this._maxDelay = this.leftDelay.delayTime.maxValue;

// add this p5.SoundFile to the soundArray
p5sound.soundArray.push(this);
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/fft.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ define(function (require) {
this.highMid = [2600, 5200];
this.treble = [5200, 14000];

// add this p5.SoundFile to the soundArray
p5sound.soundArray.push(this);
};

/**
Expand Down
3 changes: 3 additions & 0 deletions src/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ define(function (require) {
if (type) {
this.setType(type);
}

// add to the soundArray
p5sound.soundArray.push(this);
};

/**
Expand Down
3 changes: 3 additions & 0 deletions src/gain.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ define(function (require) {
// otherwise, Safari distorts
this.input.gain.value = 0.5;
this.input.connect(this.output);

// add to the soundArray
p5sound.soundArray.push(this);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/oscillator.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ define(function (require) {
}

else if (vol) {
console.log(vol);
vol.connect(self.output.gain);
} else {
// return the Gain Node
Expand Down

0 comments on commit ca1e8e8

Please sign in to comment.