Distortion getter functions

This commit is contained in:
Luke Phillips 2015-01-20 13:11:43 +00:00
parent 0717c194ae
commit a5d6ae61dc

View file

@ -22,8 +22,10 @@ define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/signal/WaveShaper"], funct
*/
this._shaper = new Tone.WaveShaper(4096);
this._distortion = options.distortion;
this.connectEffect(this._shaper);
this.setDistortion(options.distortion);
this.setDistortion(this._distortion);
this.setOversample(options.oversample);
};
@ -44,7 +46,8 @@ define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/signal/WaveShaper"], funct
* @param {number} amount amount of distortion, nominal range of 0-1.
*/
Tone.Distortion.prototype.setDistortion = function(amount) {
var k = amount * 100;
this._distortion = amount;
var k = this._distortion * 100;
var deg = Math.PI / 180;
this._shaper.setMap(function(x){
if (Math.abs(x) < 0.001){
@ -56,6 +59,14 @@ define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/signal/WaveShaper"], funct
});
};
/**
* @return {number} the amount of distortion
*/
Tone.Distortion.prototype.getDistortion = function(){
return this._distortion;
};
/**
* set the oversampling
* @param {string} oversampling can either be "none", "2x" or "4x"
@ -64,6 +75,13 @@ define(["Tone/core/Tone", "Tone/effect/Effect", "Tone/signal/WaveShaper"], funct
this._shaper.oversample = oversampling;
};
/**
* @return {string} the oversampling
*/
Tone.Distortion.prototype.getOversample = function(){
return this._shaper.oversample;
};
/**
* clean up
*/