Re: Interpolation on WaveShaperNode?

On Thu, Apr 4, 2013 at 3:27 PM, Russell McClellan <russell@motu.com> wrote:

> It doesn't seem like the spec says anything about how WaveShaperNode
> interpolates between points on the wave shaping curve.
>
> If it's really meant to be for distortion curves or that sort of thing,
> linear or better interpolation might be appropriate to reduce quantization
> noise.
>
> Currently the WebCore implementation does nearest neighbor interpolation,
> which could be quite useful for quantizing audio signals (i.e. for "bit
> crushing" or for exotic "creative uses" such as quantizing continuous LFO
> values to scales to be routed to a frequency parameter or similar).
>
> However, as a developer it feels wrong to rely on nearest neighbor
> interpolation as it is currently not guaranteed by the spec, and it seems
> decidedly suboptimal for the node's stated purpose.
>
> As perhaps you know, one can approximate the SNR of quantization to around
> 6dB * number of bits.   "CD Quality" is 16 bits, which would require a 65kb
> table.  This works in my tests, but it may surprise some developers that
> one needs a table that large to create high quality output.  Even simple
> linear interpolation would significantly reduce the number of samples
> needed to produce high quality output from a wave shaper node.
>
> Basically, my argument is this: currently, there's no advantage to using
> nearest neighbor interpolation because developer's can't depend upon it
> because it's not in the spec.  Either the webkit implementation should
> change to a better interpolation (even linear would be much better), or the
> spec should be modified to explicitly state that no interpolation will
> occur.  I guess I'd prefer the latter because it would allow developers to
> use the wave shaper as a quantizer, and it would only be a one-line change
> to the spec.
>
> Thanks,
> -Russell
>

Russell, I agree with all your points.  I think ideally we'll have an
attribute to determine the interpolation type since I believe both nearest
neighbor and linear are useful.  Then it would be a question of what the
default value for the attribute should be.  I would tend to think "linear"
would be the best default.

Another aspect of the WaveShaperNode is anti-aliasing.  In certain cases it
would be great to be able to up-sample the signal before applying the
shaping, then down-sampling.  This is to avoid the extremely harsh aliasing
that can occur in applications such as guitar amp simulations.  Once again
we could have an attribute .upsample ("none", "2x", "4x") or something like
that.  Then the default value for that would be "none" I think.

Cheers,
Chris

Received on Thursday, 4 April 2013 23:06:30 UTC