| Hi Victor,
Thanks very much for this! I'll look forward to studying it. :)
Cheers!
steven
On Tue, Jul 15, 2014 at 3:50 PM, Victor Lazzarini
wrote:
> Actually, scrap that. The cubic interpolation used by Csound does not
> use the coefficients found by this method. It’s actually much simpler:
>
> (1) Set f(-1) = p0, f(0) = p1, f(1) = p2 and f(2) = p3, with
> f(x) = ax^3 + bx^2 + cx + d
>
> (2) Solve the system
> p0 = -a + b - c + d
> p1 = d
> p2 = a + b + c + d
> p3 = 8a + 4b + 2c + d
>
> (3) The coefficients are
> a = (p3 - 3p2 + 3p1 - p0)/6
> b = (p2 - 2p1 + p0)/2
> c = -p3/6 + p2 - p1/2 - p0/3
> d = p1
>
> This actually ensures that the polynomial fits the points correctly.
> Sorry again for any confusion caused ;)
>
> ========================
> Dr Victor Lazzarini
> Senior Lecturer
> NUI Maynooth, Ireland
> victor dot lazzarini at nuim dot ie
>
> On 15 Jul 2014, at 11:39, Victor Lazzarini wrote:
>
>>> (2) The value we want is between p1 and p2, so we can start by considering what
>>> the polynomial values are for p1=0 and p2=1, f(0) and f(1)
>>
>>
>> Quick correction, p1 and p2 are not 0 and 1, but the values of f(x) at x=0 and x=1,
>> sorry for the confusion.
>>
>> ========================
>> Dr Victor Lazzarini
>> Senior Lecturer
>> NUI Maynooth, Ireland
>> victor dot lazzarini at nuim dot ie
>>
>>
>>
>>
>> On 15 Jul 2014, at 11:34, Victor Lazzarini wrote:
>>
>>> The coefficients are chosen by considering this:
>>>
>>> (1) We need to fit the polynomial f(x) = ax^3+bx^2+cx+d so it passes through
>>> the 4 points (p0,p1,p2,p3) we have sampled.
>>>
>>> (2) The value we want is between p1 and p2, so we can start by considering what
>>> the polynomial values are for p1=0 and p2=1, f(0) and f(1)
>>>
>>> f(0) = d
>>> f(1) = a+b+c+d
>>>
>>> (3) Continuing in this way, we look for the slope of the function at 0 and 1, to
>>> determine the rest of the polynomial shape. This will help us bring p0 and p3
>>> into the expression. The slope is the derivative, ie f’(x) = 3ax^2 + 2bx + c,
>>>
>>> f’(0) = c
>>> f’(1) = 3a + 2b + c
>>>
>>> (4) To relate the above to the sampled points p0…p3, we can do:
>>>
>>> f(0) = p1 and f(1) = p2 (the two points to the left and right of the region we want)
>>>
>>> and the slope at f(0) and f(1) can be determined by the simple (first-order)
>>> relations:
>>>
>>> f’(0) = (p2 - p0)/2
>>> f’(1) = (p3 - p1)/2
>>>
>>> (4) Now we have a system of equations which we can use to determine
>>> a, b, c and d.
>>>
>>> p1 = d
>>> p2 = a+b+c+d
>>> (p2 - p0)/2 = c
>>> (p3 - p1)/2 = 3a + 2b + c
>>>
>>> and from this we can work out our four coefficients.
>>>
>>> ========================
>>> Dr Victor Lazzarini
>>> Senior Lecturer
>>> NUI Maynooth, Ireland
>>> victor dot lazzarini at nuim dot ie
>>>
>>>
>>>
>>>
>>> On 15 Jul 2014, at 00:44, Steven Yi wrote:
>>>
>>>> Hi Victor,
>>>>
>>>> Thanks for mentioning that. I read through the section but I'm afraid
>>>> I'm still a little bit in the dark as to how these coefficients were
>>>> chosen. Perhaps I'll just leave it for now and come back to this
>>>> another time.
>>>>
>>>> Thanks!
>>>> steven
>>>>
>>>> On Mon, Jul 14, 2014 at 2:48 PM, Victor Lazzarini
>>>> wrote:
>>>>> Have a look at the Audio Programming book, “time-domain audio programming”, I explain
>>>>> the cubic interpolation method there.
>>>>>
>>>>> ========================
>>>>> Dr Victor Lazzarini
>>>>> Senior Lecturer
>>>>> NUI Maynooth, Ireland
>>>>> victor dot lazzarini at nuim dot ie
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 14 Jul 2014, at 19:09, Steven Yi wrote:
>>>>>
>>>>>> I was looking at this paper "Polynomial Interpolators for High-Quality
>>>>>> Resampling of Oversampled Audio" by Olli Niemitalo [1] and found a
>>>>>> number of approaches. For example, it looks like he's contributed a
>>>>>> cubic formula to the musicdsp wiki[2] (looks to correspond to the
>>>>>> "4-point, 3rd-order Hermite (x-form)" in the paper). I wasn't sure
>>>>>> what interpolation scheme was used in oscil3 (plus, my maths is not
>>>>>> very good. :P).
>>>>>>
>>>>>> [1] - http://yehar.com/blog/?p=197
>>>>>> [2] - http://musicdsp.org/archive.php?classid=5#49
>>>>>>
>>>>>> On Mon, Jul 14, 2014 at 1:49 PM, wrote:
>>>>>>> ?? Cubic interpolation fits a cubic curve (Ax^3 + Bx^2 + Cx +D)
>>>>>>> through four points, two below point in question and 2 above. Not
>>>>>>> sure what you are asking
>>>>>>>
>>>>>>> Quoting Steven Yi :
>>>>>>>
>>>>>>>> Hi All,
>>>>>>>>
>>>>>>>> I was looking at oscil3 and table3 and cubic interpolation in general.
>>>>>>>> Could someone tell me what kind of interpolation this is? (This is in
>>>>>>>> OOps/ugens2.c) I'm wondering too if we couldn't make an inline
>>>>>>>> function reuse in the various places to make it a little easier to
>>>>>>>> understand this bit of code.
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>> steven
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Want fast and easy access to all the code in your enterprise? Index and
>>>>>>>> search up to 200,000 lines of code with a free copy of Black Duck®
>>>>>>>> Code Sight - the same software that powers the world's largest code
>>>>>>>> search on Ohloh, the Black Duck Open Hub! Try it now.
>>>>>>>> http://p.sf.net/sfu/bds
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Want fast and easy access to all the code in your enterprise? Index and
>>>>>>> search up to 200,000 lines of code with a free copy of Black Duck®
>>>>>>> Code Sight - the same software that powers the world's largest code
>>>>>>> search on Ohloh, the Black Duck Open Hub! Try it now.
>>>>>>> http://p.sf.net/sfu/bds
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Want fast and easy access to all the code in your enterprise? Index and
>>>>>> search up to 200,000 lines of code with a free copy of Black Duck®
>>>>>> Code Sight - the same software that powers the world's largest code
>>>>>> search on Ohloh, the Black Duck Open Hub! Try it now.
>>>>>> http://p.sf.net/sfu/bds
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Want fast and easy access to all the code in your enterprise? Index and
>>>>> search up to 200,000 lines of code with a free copy of Black Duck®
>>>>> Code Sight - the same software that powers the world's largest code
>>>>> search on Ohloh, the Black Duck Open Hub! Try it now.
>>>>> http://p.sf.net/sfu/bds
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Want fast and easy access to all the code in your enterprise? Index and
>>>> search up to 200,000 lines of code with a free copy of Black Duck
>>>> Code Sight - the same software that powers the world's largest code
>>>> search on Ohloh, the Black Duck Open Hub! Try it now.
>>>> http://p.sf.net/sfu/bds
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Want fast and easy access to all the code in your enterprise? Index and
>>> search up to 200,000 lines of code with a free copy of Black Duck
>>> Code Sight - the same software that powers the world's largest code
>>> search on Ohloh, the Black Duck Open Hub! Try it now.
>>> http://p.sf.net/sfu/bds
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> Want fast and easy access to all the code in your enterprise? Index and
>> search up to 200,000 lines of code with a free copy of Black Duck
>> Code Sight - the same software that powers the world's largest code
>> search on Ohloh, the Black Duck Open Hub! Try it now.
>> http://p.sf.net/sfu/bds
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Want fast and easy access to all the code in your enterprise? Index and
> search up to 200,000 lines of code with a free copy of Black Duck
> Code Sight - the same software that powers the world's largest code
> search on Ohloh, the Black Duck Open Hub! Try it now.
> http://p.sf.net/sfu/bds
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ |