Do not forget to see an example here .
In detail, I create a wavechaper curve with this function:
WAAMorningStar.prototype.createWSCurve = function (amount, n_samples) { if ((amount >= 0) && (amount < 1)) { ND.dist = amount; var k = 2 * ND.dist / (1 - ND.dist); for (var i = 0; i < n_samples; i+=1) {
Then βloadβ it into the wavemaper node as follows:
this.createWSCurve(ND.dist, this.nSamples); this.sigmaDistortNode = this.context.createWaveShaper(); this.sigmaDistortNode.curve = this.wsCurve;
Every time I need to change the distortion parameter, I again create a wavechaper curve:
WAAMorningStar.prototype.setDistortion = function (distValue) { var distCorrect = distValue; if (distValue < -1) { distCorrect = -1; } if (distValue >= 1) { distCorrect = 0.985; } this.createWSCurve (distCorrect, this.nSamples); }
(I use distCorrect to make the distortion sound more enjoyable, values ββfound heuristically). You can find the algorithm that I use to create the wavehaper curve here
janesconference
source share