From 85c4c03076dd4bc6982f4c6c337b13fdb59b2b46 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Tue, 25 Oct 2016 22:00:21 -0400 Subject: [PATCH] pitch shift effect 10 units per semitone --- src/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index e351695..feb5a4c 100644 --- a/src/index.js +++ b/src/index.js @@ -14,7 +14,7 @@ function AudioEngine (sounds) { this.delay = new Tone.FeedbackDelay(0.25, 0.5); this.panner = new Tone.Panner(); this.reverb = new Tone.Freeverb(); - this.pitchShiftRatio; + this.pitchEffectValue; // the effects are chained to an effects node for this clone, then to the master output // so audio is sent from each player or instrument, through the effects in order, then out @@ -152,7 +152,7 @@ AudioEngine.prototype.setEffect = function (effect, value) { this.reverb.wet.value = value / 100; break; case 'PITCH': - this._setPitchShift(value / 100); + this._setPitchShift(value); break; } }; @@ -172,20 +172,21 @@ AudioEngine.prototype.changeEffect = function (effect, value) { this.reverb.wet.value = this._clamp(this.reverb.wet.value, 0, 1); break; case 'PITCH': - this._setPitchShift(this.pitchShiftRatio + (value / 100)); + this._setPitchShift(this.pitchEffectValue + Number(value)); break; } }; AudioEngine.prototype._setPitchShift = function (value) { - this.pitchShiftRatio = value; + this.pitchEffectValue = value; if (!this.soundPlayers) { return; } + var ratio = this.tone.intervalToFrequencyRatio(this.pitchEffectValue / 10); for (var i=0; i