diff --git a/src/effects/PitchEffect.js b/src/effects/PitchEffect.js index cb4107b..b92ba1a 100644 --- a/src/effects/PitchEffect.js +++ b/src/effects/PitchEffect.js @@ -8,12 +8,14 @@ var Tone = require('tone'); function PitchEffect () { this.value = 0; + this.ratio = 1; this.tone = new Tone(); } PitchEffect.prototype.set = function (val, players) { this.value = val; + this.ratio = this.getRatio(this.value); this.updatePlayers(players); }; @@ -21,19 +23,23 @@ PitchEffect.prototype.changeBy = function (val, players) { this.set(this.value + val, players); }; -PitchEffect.prototype.getRatio = function () { - return this.tone.intervalToFrequencyRatio(this.value / 10); +PitchEffect.prototype.getRatio = function (val) { + return this.tone.intervalToFrequencyRatio(val / 10); +}; + +PitchEffect.prototype.updatePlayer = function (player) { + player.setPlaybackRate(this.ratio); }; PitchEffect.prototype.updatePlayers = function (players) { if (!players) return; - var ratio = this.getRatio(); - for (var i=0; i { + delete this.activeSoundPlayers[md5]; }); }; @@ -168,9 +178,9 @@ AudioPlayer.prototype.beatsToSec = function (beats) { }; AudioPlayer.prototype.stopAllSounds = function () { - // stop all sound players - for (var i=0; i