        SOUND INTERPOLATION ALGORITHMS                                v19980602
        by Yehar

        
        "Fake sinc". Cubic through 2 known points. Continuous differential.
        Differential of the curve at a known sample point = precalculated
        derivat of sinc interpolation curve at the same point. Fast in use,
        very high quality, 4x memory consumption, for systems where sampledata
        doesn't change in action.
        
        Known sample points:

          All of them!

          Interpolation between points x=0 and x=1

        Interpolated sample:

          f(x) = ax^3 + bx^2 + cx + y(0)   (x=0..1)

            where

          a = 2*y(0) - 2*y(1) + k(0) + k(1)
          b = 3*y(1) - 3*y(0) - 2*k(0) - k(1)
          c = k(0)
          d = y(0)

            where

                  max
                 ____
                 \   |
          k(0) =  >    pi * d_sinc(pi * i) * y(i)
                 /___|

                i = min

                  max
                 ____
                 \   |
          k(1) =  >    pi * d_sinc(pi * (i-1)) * y(i)
                 /___|

                i = min

        The math behind this:

          f(x) = ax^3 + bx^2 + cx + d

           / f(0) = y(0)
          |
          |  f(1) = y(1)
         <
          |  f'(0) = k(0)
          |
           \ f'(1) = k(1)

          k(0) and k(1) calculated with sinc interpolation.

        How to use:

          Precalculate a, b and c values for all sample points in memory.
          After that, when you interpolate a sample, all you need to do is:

            a * x
            a + b
            a * x
            a + c
            a * x
            a + y(0)

            out = a

            (total 3 muls, 3 adds)

        
        "Hermite curve". Cubic through 2 known points. Continuous differential.
        Differential of the curve at a known sample point = slope of a straight
        line drawn through the two neigbouring known points.
        
        Known sample points:

          y(-1), y(0), y(1), y(2)

          Interpolation takes place between points x=0 and x=1

        Interpolated sample:

          f(x) = ax^3 + bx^2 + cx + y(0)   (x=0..1)

            where

              3 ( y(0) - y(1) ) - y(-1) + y(2)
          a = --------------------------------
                             2

                               5 y(0) + y(2)
          b = 2 y(1) + y(-1) - -------------
                                     2

              y(1) - y(-1)
          c = ------------
                   2

        The math behind this:

          f(x) = ax^3 + bx^2 + cx + d

           / f(0) = y(0)
          |
          |  f(1) = y(1)
         <
          |  f'(0) = (y(1) - y(-1)) / 2
          |
           \ f'(1) = (y(2) - y(0)) / 2

        Optimized pseudocode: (3 muls, 19 adds/subs/shifts)

          a = y(0)
          a - y(1)
          a sal 2
          a - y(0)
          a + y(1)
          a - y(-1)
          a + y(2)
          a sar 1

          temp = y(0)
          temp sal 2
          temp + y(0)
          temp + y(2)
          temp sar 1
          b = y(1)
          b + y(1)
          b + y(-1)
          b - temp

          c = y(1)
          c - y(-1)
          c sar 1

          a * x
          a + b
          a * x
          a + c
          a * x
          a + y(0)

          out = a
          
        

        Hermite curve:
                                     +*
                                    +  |
                                   +   +
                                  |    |
                                  +     |
                                  |     +
                                 |      |
                                 +       |
                                |        |
                                +        +
                               |         |
                               +          |
                              *           |
                             +            +
                            +             |
                          ++              |
      *       *       *+++                 |                          *       *
               +++++++                     |                         +
                                           +                        |
                                           |                        +
                                            |                      +
                                            |                     |
                                            +                     +
                                            |                    |
                                             |                   +
                                             |                  |
                                             +                  +
                                              |                +
                                              *               *
                                               |             +
                                               +            +
                                                +         ++
                                                 ++   *+++
                                                   +++
        Linear interpolation:

                                      *
                                     + |
                                    +  +
                                   |   |
                                   +    |
                                  +     |
                                 |      +
                                 +      |
                                +        |
                               |         |
                               +         +
                              |          |
                             +*           |
                           ++             |
                         ++               +
                       ++                 |
      *+++++++*+++++++*                    |                          *+++++++*
                                           |                         +
                                           +                        +
                                           |                       |
                                            |                      +
                                            |                     +
                                            +                    |
                                            |                    +
                                             |                  +
                                             |                 |
                                             +                 +
                                              |               |
                                              *              +*
                                               ++          ++
                                                 ++      ++
                                                   ++  ++
                                                     +*
        No interpolation:

                                   +++*++++
                                   |      |
                                   |      |
                                   |      |
                                   |      |
                                   |      |
                                  |       |
                                  |       |
                                  |       |
                                  |       |
                                  |       |
                                  |       |
                           +++*++++       |
                           |              |
                          |                |
                          |                |
      *+++++++*+++++++*++++                |                       +++*+++++++*
                                           |                       |
                                           |                       |
                                           |                       |
                                           |                       |
                                           |                       |
                                           |                      |
                                           |                      |
                                           |                      |
                                           |                      |
                                           |                      |
                                           |                      |
                                           +++*++++        +++*++++
                                                  |        |
                                                   |      |
                                                   |      |
                                                   +++*++++
