add stopall function for instruments and drums

This commit is contained in:
Eric Rosenbaum 2017-01-10 18:02:45 -05:00
parent 193a9f181b
commit 703502cfbb
3 changed files with 19 additions and 10 deletions

View file

@ -11,6 +11,10 @@ function DrumPlayer (outputNode) {
DrumPlayer.prototype.start = function () {
this.snare.start();
DrumPlayer.prototype.stopAll = function () {
for (var i=0; i<this.drumSounds.length; i++) {
this.drumSounds[i].stop();
}
};
module.exports = DrumPlayer;

View file

@ -36,4 +36,12 @@ InstrumentPlayer.prototype.loadInstrument = function (instrumentNum) {
}
};
InstrumentPlayer.prototype.stopAll = function () {
for (var i=0; i<this.instruments.length; i++) {
if (this.instruments[i]) {
this.instruments[i].stop();
}
}
};
module.exports = InstrumentPlayer;

View file

@ -141,20 +141,17 @@ AudioPlayer.prototype.beatsToSec = function (beats) {
};
AudioPlayer.prototype.stopAllSounds = function () {
// stop drum notes
// for (var i = 0; i<this.drumSamplers.length; i++) {
// this.drumSamplers[i].triggerRelease();
// }
// stop sounds triggered with playSound
// stop all sound players
for (var i=0; i<this.soundPlayers.length; i++) {
this.soundPlayers[i].stop();
}
// stop soundfont notes
// if (this.instrument) {
// this.instrument.stop();
// }
// stop all instruments
this.audioEngine.instrumentPlayer.stopAll();
// stop drum notes
this.audioEngine.drumPlayer.stopAll();
};
AudioPlayer.prototype.setEffect = function (effect, value) {