audio - WaveShaper node in WebAudio - how to emulate distortion? -
working webaudio api , trying distortion going! issue is, i'm not sure how "curve" param of waveshaper.
simply put, 'oscidis' waveshaper node created earlier in program. oscidisv value have set 0 statically, now.:
var wscurve = new float32array(); if ((oscidisv >= -1) && (oscidisv < 1)) { var k = 2 * oscidisv / (1 - oscidisv); console.log (var = 0; < 16; i+=1) { // linear interpolation: x := (c - a) * (z - y) / (b - a) + y // = 0, b = 2048, z = 1, y = -1, c = var x = (i - 0) * (1 - (-1)) / (16 - 0) + (-1); wscurve[i] = (1 + k) * x / (1+ k * math.abs(x)); } } oscidis.curve.value = wscurve; the issue - i'm not hearing difference in sound regardless of put here )-=. don't notice real distortion distortion @ max (1). guys know more noticeable distortion waveshaping function? or if i'm doing right @ in webaudio api?
here's 1 i've used that's based on few different functions i've found in white papers , things that:
function makedistortioncurve( amount ) { var k = typeof amount === 'number' ? amount : 50, n_samples = 44100, curve = new float32array(n_samples), deg = math.pi / 180, = 0, x; ( ; < n_samples; ++i ) { x = * 2 / n_samples - 1; curve[i] = ( 3 + k ) * x * 20 * deg / ( math.pi + k * math.abs(x) ); } return curve; }; i'd lying if told knew 3 + k or 20 come — works.
the value of amount can positive number, i've found 0 - 100 pretty range depending on how distortion need.
if have interest in seeing these functions like, built little tool me visualize them here: http://kevincennis.github.io/transfergraph/
Comments
Post a Comment