- From: robert bristow-johnson <rbj@audioimagination.com>
- Date: Thu, 04 Apr 2013 21:57:36 -0400
- To: public-audio@w3.org
On 4/4/13 7:06 PM, Chris Rogers wrote: > 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. just lurking, and i haven't looked at the code at all, but thought i might mention a couple of things that might be applicable. if you can get away from table lookup and implement the waveshaper by use of a pure polynomial if finite order, you can get a solid handle on aliasing. a finite-order polynomial is not as general and a general lookup table, but for the purposes of distortion (or "warmth" or whatever) in audio, it might be closer to what you want anyway. you can fit polynomials to tube curves and the sort pretty well. the images generated is no higher in frequency than the order of the polynomial (let's call that M) times the highest frequency. if that highest frequency is potentially Nyquist, then upsampling by a factor of N means that the highest frequency is the *new* Nyquist/N. that makes the highest frequency image (M/N)*Nyquist. you can allow aliases as long as they don't get back into your original baseband which is below the new Nyquist/N. that means 2*Nyquist - (M/N)*Nyquist > Nyquist/N or 2*N - M > 1 or M < 2*N - 1 if you upsample by 2x, you can have a 3rd-order polynomial. if you upsample by 4x, you can have a 7th-order polynomial. then a decent brick-wall LPF with cutoff at Nyquist/N to kill the images and aliases. then downsample by factor of N and you have output. you will get the distortion components you were meant to get (harmonics) and no non-harmonic components which are the tell-tales of aliasing and cheezy distortion. you can do this with table lookup if you make sure the table ain't defined to wildly (like if it's implementing a Mth-order polynomial), have enough points in the table (memory is cheap), and at least linearly interpolate between points. how many points you need (based on what interpolation is done between points) in the table is something that i had done some analysis about long ago, but i might be able to find notes. if computational burden is no problem, i might suggest implementing this as a polynomial and use Horner's rule. just an idea. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Received on Friday, 5 April 2013 01:58:08 UTC