SynthMaker

interpolations : linear, cubic and spline

Archive · 2006 27 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

lalo ·

hi guys,

i'm studying interpolation methods..

i suggest you to load a simple sine wave sample to check

1. no interpolation 2. linear interpolation 3. cubic interpolation

cubic is slightly better...but i have to study spline and sinc interpolation...

hope i'll be able to understand the mathematics 🙂

lalo

http://rapidshare.de/files/18158670/int ... s.osm.html

sambean ·

Can't download from rabidshare at the mo.. But here's a rather extesive list of interpolation methods..

http://www.biochem.oulu.fi/~oniemita/dsp/deip.pdf 😮

I'd skim over all the technical nonsense in the first half of the document and look to the code examples at the bottom

eg

// 4-point, 3rd-order B-spline (x-form) float ym1py1 = y[-1]+y[1]; float c0 = 1/6.0*ym1py1 + 2/3.0*y[0]; float c1 = 1/2.0*(y[1]-y[-1]); float c2 = 1/2.0*ym1py1 - y[0]; float c3 = 1/2.0*(y[0]-y[1]) + 1/6.0*(y[2]-y[-1]); return ((c3*x+c2)*x+c1)*x+c0;

The y[-1], y[0], etc correspond to the samples values around the value you wish to sample eg if sampling at 34.2

y[-1] = 33, y[0] = 34, y[1] = 35, y[2] = 36..

and x corresponds to the fractional value 0.2..

Shouldn't be too difficult convering these into schematics..

I look forward to any results you get, this is something thats been at the back of my mind for a while.. It would be nice to have a wave read module with one input and a whole selection of interpolation methods as properties..

Cheers

Sam

lalo ·

sambean wrote: t would be nice to have a wave read module with one input and a whole selection of interpolation methods as properties..

a beginning of it 🙂

..my .osm at rapidshare has no interpolation , linear and cubic 😉

lalo ·

arghh... i made i mistake in cubic interpolation....

correct pos1 and pos2

they should be

pos1=int-1; and not int-2 pos2=int; and not int-1

in the cubic interpolation code block

lalo

p.s now it sound peeerfectly..far better 🙂

chek it out by yourself...

chose a super fractional pitch value and change the interpolators in realtime 😉 ...with a sine sample to check quality

http://rapidshare.de/files/18163796/int ... s.osm.html

sambean ·

Can't download it yet.... 😠

One way I suggest testing it is by subtracting the exact calculated sine value from a code module from you're sampled/interpolated value, the remainder that is left will be the error.. Should be visible using an analyser..

Sam

lalo ·

sambean wrote: Can't download it yet.... 😠

One way I suggest testing it is by subtracting the exact calculated sine value from a code module from you're sampled/interpolated value, the remainder that is left will be the error.. Should be visible using an analyser..

Sam

why you can't download?

good idea about the subtraction 😉

lalo ·

uploaded with spline algorythm found by sambean (thanx m8 😇 )

cubic seems better 'cause spline is heavy low-pass filtering....but it depends on the material you are playing with the buffer...

i've upladed the .osm as a .txt cuase my server doesn't like .osm....

just change the extension to .osm and open with SM 🙂

lemme know what you think....

http://www.nusic.org/temps/interpolations.txt

lowe

lalo

sambean ·

Hey Lalo, finally got it!

Have had a wee look round.. Some of it's working some not..

The spline and the cubic seem fine, a quick suggestion though: if you're going to divide by numbers, it's probably better to multiply by 1OverNumber ie instead of having x = y/3, use x = y*0.333333... It's harder to read at this stage, but it's better doing this now rather than having to come back later on.. Divide takes about 20x the cpu than a multiply..

In the linear section You have the fraction and 1-fraction going to the wrong sections, this is why the linear is sounding brighter.. rndint rounds to nearest so to round down I've changed this to int = rndint(index-0.5).. This isn't necessary with the others, I'm not sure why..

I've updated with these changes and also added mono support for the spline section, should be easy to add to the others.. I've switched to a selector instead of a multiplexer too, with multiplexers and poly sections the cpu from the other sections is not stopped.. I've also neatened it up a little..

http://magalov.myweb.hinet.net/toolkit/interp_sam.osm

Cheers

Sam

Shifrin ·

Interesting stuff guys, so far I've not really looked much at this sort of interpolation - too busy with other things - but there's some useful information here 🙂

That interpolation scheme pdf is very useful - I think I already had it sitting somewhere on my machine - but I'm glad to see it posted!

Cheers guys,

Shif.

lalo ·

well done sam...

yes i konw about division cpu cost...at this stage i was trying to keep readabilty for me to understand better 🙂

i thought rndint round to the lower integer...

i have to understand why cubic and spline works anyway 🙂

lalo ·

another version... corrected some bug introduced by sam's bug fixing 🙂

and some bug introduced by stupeed me...

now all shoukd be good 🙂

i'll do some mid-level buffer things (mono and stereo) where you can chose interpolation algorythm in the properties menu 😉

http://www.nusic.org/temps/interp_sam_lalo.txt

...change .txt in .osm 😉

dasdeck ·

hey, thans, but doesn't serious inperpolation use oversampling? i don't grasp this stuff too good, as my math is not good enough yet, 'im a new student and have some audiofreak profs., so i think i'll grasp it during my studiing

greetz

D3CK 🙂

Shifrin ·

dasdeck wrote: but doesn't serious inperpolation use oversampling

Not to my knowledge! Of course I am open to being corrected 😉

Shif.

stefan ·

dasdeck wrote: hey, thans, but doesn't serious inperpolation use oversampling? i don't grasp this stuff too good, as my math is not good enough yet, 'im a new student and have some audiofreak profs., so i think i'll grasp it during my studiing

greetz

D3CK 🙂

You don't need any oversampling to do "perfect" interpolation. To do low alias up-pitching you probably want to do oversampling though, but that's another issue.

lalo ·

stefan wrote: You don't need any oversampling to do "perfect" interpolation. To do low alias up-pitching you probably want to do oversampling though, but that's another issue.

yes...avoiding aliasing is another issue....too complex for me now.... but maybe in some months... 😉

dasdeck ·

good to hear, i mostly use samples for drums and other rythmic sounds. not too much up-pitching involved here, but i need downpitching a lot!

thanks for the sinc interpol, it sounds better on bass drums then the others, wich i had berfore, but found to be unusable.#

may it be that you can raise the order of the spline interpolation? i mean can it be that you can use more points than four to interpolate?

and for downpitching, wouldn't some kind of dither be kool to avoid the "pixeling" ?

anyway, i don't have too much knowledge about all this stuff, but i have the experience that samplers sound different when samples are pitched (and soemtimes even unpitched", and i do have favourites.

D3CK

sambean ·

For some reason the blue connectors seem to be taking over the schematic.. Could be a bug..

Some cpu stat estimates: no interp- 90 cycles/sample linear- 260 spline- 430 cubic - 450..

infuzion ·

stefan wrote: You don't need any oversampling to do "perfect" interpolation. To do low alias up-pitching you probably want to do oversampling though, but that's another issue.

I could use up-sampling, but I use Live for it now.

stefan ·

infuzion wrote: stefan wrote: You don't need any oversampling to do "perfect" interpolation. To do low alias up-pitching you probably want to do oversampling though, but that's another issue.

I could use up-sampling, but I use Live for it now.

Just for the clarity of things: Up-pitching = down-sampling Down-pitching = up-sampling

🙂

infuzion ·

ah, I wanna go faster for now, slower later...

dasdeck ·

hey bros, in the last example you add -0.5 to the fractional value before you round to int, are you shure about that?, i mean, it always rounds down, so form case to case it would go down one or to steps:

1,2-> -0,5 -> round = 0 1,7-> -0,5 -> round = 1

schould not both be 1?

or the second one 2?

anyway, i think i gave the answer ma self, as a addition of 0,5 or -0,5 seems nessesarry tom me now.

thanks 🙂

please comment if i'm wrong

D3CK

p.s.: is mathematical rounding nesesary here or just cosmetic?

sambean ·

The method SM uses for rounding always rounds to nearest, so to round down you need to subtract the 0.5..

Try putting the following code into an analyser

streamin in; streamout out; out = rndint(in);

You'll find the output always round to nearest..

And rounding is necessary to get the fractional amount:

fract = value - floor(value);

Cheers

Sam

lalo ·

waht sam said 🙂

dasdeck ·

thanks 🙂

i have added hermite, lagrange and osculating4 point versions, herimite seems best to me so far.

I' ll up them if i got some more 🙂

its acool pdf, its copy and paste, cool.

D3CK

dasdeck ·

sambean wrote: Can't download from rabidshare at the mo.. But here's a rather extesive list of interpolation methods..

http://www.biochem.oulu.fi/~oniemita/dsp/deip.pdf 😮

I'd skim over all the technical nonsense in the first half of the document and look to the code examples at the bottom

eg

// 4-point, 3rd-order B-spline (x-form) float ym1py1 = y[-1]+y[1]; float c0 = 1/6.0*ym1py1 + 2/3.0*y[0]; float c1 = 1/2.0*(y[1]-y[-1]); float c2 = 1/2.0*ym1py1 - y[0]; float c3 = 1/2.0*(y[0]-y[1]) + 1/6.0*(y[2]-y[-1]); return ((c3*x+c2)*x+c1)*x+c0;

The y[-1], y[0], etc correspond to the samples values around the value you wish to sample eg if sampling at 34.2

y[-1] = 33, y[0] = 34, y[1] = 35, y[2] = 36..

and x corresponds to the fractional value 0.2..

Shouldn't be too difficult convering these into schematics..

I look forward to any results you get, this is something thats been at the back of my mind for a while.. It would be nice to have a wave read module with one input and a whole selection of interpolation methods as properties..

Cheers

Sam

do you have a copy of that paper you linked to? its away and i've lost my copy.

thanks

D3CK

Shifrin ·

You should be able to find the paper here :-

http://yehar.com/dsp/deip.pdf

Shif.

dasdeck ·

Shifrin wrote: You should be able to find the paper here :-

http://yehar.com/dsp/deip.pdf

Shif.

thanks! 😀

i googled it but seems there are other deip.pdfs out there.

D3CK

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.