[PD] waveshaping with a lookup table (idiot question)

Mathieu Bouchard matju at artengine.ca
Tue Nov 22 04:17:00 CET 2005

On Mon, 21 Nov 2005, james holden wrote:

> i'm attempting waveshaping using a lookup table and tabread4~. my table
> contains a linear ramp at the moment. but:
> what i've noticed though is with a small table (100 points) i get a distortion
> that sounds like bit-depth reduction. it goes with a larger table. surely
> though, if tabread4~ interpolates this shouldn't happen? have i just made a
> buggy patch or is there a finer point i'm missing?

With a four-point interpolator you're supposed to be able to get perfectly 
any linear ramp, or even quadratic ramp or cubic ramp. If you don't then 
something else is wrong. How do you fill your table? How do you use 
[tabread4~] to sample it?

Whatever your input range is, you have to correctly scale it to fit the
coords of your table. So with a 100-point table with 4-point centered
interpolation, you have to use indices in the range from 2 to 97 (that is,
reserve two indices at each end of the table). Thus if your input signal
is in the range from -1 to +1, you will need to rescale it like:

  [expr~ 2+($v1 - -1)*(97 - 2)/(1 - -1)]

that is:

  [expr~ 49.5+$v1*47.5]

or just:

  [*~ 47.5]
  [+~ 49.5]

Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju
Freelance Digital Arts Engineer, Montréal QC Canada

More information about the Pd-list mailing list