WebAudio / web-audio-api

The Web Audio API v1.0, developed by the W3C Audio WG
https://webaudio.github.io/web-audio-api/
Other
1.05k stars 168 forks source link

Describe how WaveShaperNode shapes the input with the curve #1943

Closed rtoy closed 5 years ago

rtoy commented 5 years ago

The description of the WaveShaperNode says linear interpolation is used (see also #87). But the fine details are a bit lacking.

Perhaps a formula and/or picture would make it clearer on how it's done. At least for the case of oversample = none. The oversampling cases are purposely rather loose so you can do the up-sampling and down-sampling in whatever way. But the application of the curve is basically the same. in all cases.

svgeesus commented 5 years ago

So basically an input vs. output graph to show how the shaping transfer function is produced from the curve array, and then an input waveform to output waveform example to show the effect of the shaping? That looks like a relatively easy graphic.

svgeesus commented 5 years ago

Also am I reading this right, that a curve with a single value is allowed, and results in a transfer curve which is a horizontal line (resulting in a straight DC output)?

rtoy commented 5 years ago

Paragraph 4 in https://webaudio.github.io/web-audio-api/#WaveShaperNode-attributes explicitly disallows curves of one (or fewer) elements.

Not sure where the best place to put this picture. Maybe add a new subsection at the end of the WaveShaper section, kind of like what we do for Biquads, IIRs, and Oscillators?