http://redmine.jamoma.org/2012-11-27T13:41:10ZJamoma DevelopmentDSP - Tasks #1253: TTDelay cubic interpolation decisionhttp://redmine.jamoma.org/issues/1253?journal_id=24372012-11-27T13:41:10ZNathan Woleknw@nathanwolek.com
<ul></ul><p>This looks like it:<br /><a class="external" href="http://stackoverflow.com/questions/1125666/how-do-you-do-bicubic-or-other-non-linear-interpolation-of-re-sampled-audio-da">http://stackoverflow.com/questions/1125666/how-do-you-do-bicubic-or-other-non-linear-interpolation-of-re-sampled-audio-da</a></p>
<p>Some other links of interest:<br /><a class="external" href="http://yehar.com/blog/?p=197">http://yehar.com/blog/?p=197</a><br /><a class="external" href="http://www.csounds.com/ezine/summer2000/internals/">http://www.csounds.com/ezine/summer2000/internals/</a></p> DSP - Tasks #1253: TTDelay cubic interpolation decisionhttp://redmine.jamoma.org/issues/1253?journal_id=24392012-11-28T19:55:15ZTrond Lossiustrond.lossius@bek.no
<ul></ul><p>I'm currently looking into the interpolation algorithms. I don't have any final conclusions yet, but so far the algorithm in DSP seems trustworthy while I'm less convinced about the one in Foundation. But I'm in the process of implementing unit tests for TTInterpolate in Foundation.</p> DSP - Tasks #1253: TTDelay cubic interpolation decisionhttp://redmine.jamoma.org/issues/1253?journal_id=24402012-11-28T22:17:57ZTrond Lossiustrond.lossius@bek.no
<ul><li><strong>Branch</strong> set to <i>master</i></li></ul><p>I have just added some unit tests for TTInterpolate in Foundation Library (commit f4088a5a5), and they indicate that something is wrong with the cubic interpolator there, at least if it's supposed to work the same way as the interpolator in DSP Library.</p> DSP - Tasks #1253: TTDelay cubic interpolation decisionhttp://redmine.jamoma.org/issues/1253?journal_id=24432012-12-02T21:49:31ZTrond Lossiustrond.lossius@bek.no
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>Applied in changeset commit:b889d1a2484e1048aa24eac7b42d75f7461281d2.</p> DSP - Tasks #1253: TTDelay cubic interpolation decisionhttp://redmine.jamoma.org/issues/1253?journal_id=24442012-12-02T22:01:44ZTrond Lossiustrond.lossius@bek.no
<ul></ul><p>After several days of investigations I have come to the following conclusions:</p>
<p>With the commits done today we now have two differing polynimical interpolation algorithms mplemented. They are now both correctly implemented, but differ in their assumptions.</p>
<a name="FoundationLibraryTTInterpolate"></a>
<h3 >Foundation/Library/TTInterpolate:<a href="#FoundationLibraryTTInterpolate" class="wiki-anchor">¶</a></h3>
<p>The assumptions are now thoroughly documented in the header file:</p>
<pre>
@details This interpolation algorithms calculate the coefficients a, b, c, d
of the 3rd order polynomial
f(delta) = a*aDelta^3 + b*aDelta^2 + c*aDelta + d
= ( (a*aDelta + b )*aDelta + c)*aDelta + d)
so that the function fulfill the following four conditions:
-# f(0) = x1 @n
-# f(1) = x2 @n
-# f'(0) = (x2-x0)/2 @n
-# f'(1) = (x3-x1)/2
The two last conditions use a symetric estimate of the difference at the end points
of the region to interpolate over: 0 ≤ aDelta ≤ 1
These asumptions ensure that the resulting interpolated function, when moving over several
subsequent sections, is:
-# Continuous (no sudden jump)
-# Has a continuous derivative (no break pints with hard edges)
However, the 2nd order derivate will generally be discontinuous on the points connecting two sections.
</pre>
<a name="DSPLibrary"></a>
<h3 >DSP/Library<a href="#DSPLibrary" class="wiki-anchor">¶</a></h3>
<p>This interpolation is based on the following four assumptions:</p>
<ol>
<li>(f(-1) = x0 </li>
<li>f(0) = x1</li>
<li>f(1) = x2</li>
<li>f(2) = x3</li>
</ol>
<p>This ensures that the interpolated function pass through all four points. However, this function has to be expected to have a discontionuous derivative at the connection points (this might appear as hard edges in the resulting interpolated curve).</p>
<a name="Conclusion"></a>
<h3 >Conclusion<a href="#Conclusion" class="wiki-anchor">¶</a></h3>
<p>For audio interpolation purposes the function in Foundation is probably preferable, as it is expected to introduce less artificial spectral noise.</p> DSP - Tasks #1253: TTDelay cubic interpolation decisionhttp://redmine.jamoma.org/issues/1253?journal_id=24452012-12-02T22:34:12ZTrond Lossiustrond.lossius@bek.no
<ul></ul><p>Here are the calculations involved, documented for posterity:</p>
<pre>
f(t) = a t^3 + b t^2 + c t + d
f'(t) = 3a t^2 + b t + c
----
f(0) = x
=> d = x (1)
---
f'(0) = (y-w)/2 = c
=> c = -0.5 w + 0.5 y (2)
---
f(1) = a + b + c + d = y
a + b = y - (-0.5w + 0.5y) - x
a + b = y + 0.5w -0.5 y - x
2a + 2b = w - 2x + y (3)
---
f'(1) = 3a + 2b + c = (z-x)/2
6a + 4b = z - x - 2c
6a + 4b = z - x - 2 (-0.5 w + 0.5 y)
6a + 4b = z - x + w - y
6a + 4b = w - x - y + z (4)
---
Combining (3) and (4)
2a = -w + 3x -3y + z (5)
a = -0.5w + 1.5x - 1.5y + 0.5z
Combining (3) and (5)
2b = w - 2x + y - ( -w + 3x -3y + z )
2b = w - 2x + y + w - 3x + 3y - z
2b = 2w - 5x + 4y - z
b = w - 2.5x + 2y - 0.5z
---
Checking that conditions are satisfied:
f(1) = a + b + c + d
= ( -0.5w + 1.5x - 1.5y + 0.5z ) + ( w - 2.5x + 2y - 0.5z ) + ( -0.5 w + 0.5 y ) + x
= -0.5w + 1.5x - 1.5y + 0.5z + w - 2.5x + 2y - 0.5z - 0.5 w + 0.5 y + x
= y
f'(1) = 3a + 2b + c
= 3( -0.5w + 1.5x - 1.5y + 0.5z ) + 2( w - 2.5x + 2y - 0.5z ) + ( -0.5 w + 0.5 y )
= -1.5w + 4.5x - 4.5y + 1.5z + 2w - 5x + 4y - z - 0.5 w + 0.5 y
= 4.5x + 1.5z - 5x - z
= -0.5x + 0.5z
= (z-x)/2
</pre>