SynthMaker

Interpolation

Archive · 2010 13 old posts

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

mwvdlee ·

The standard wave player uses interpolation to handle differences between the sample rate of the host and the sample rate of the wave. It uses a linear interpolation.

Now my background is in graphics rather than sound, but in graphics linear interpolation isn't considered very good. It's better than none, but far worse than other common methods. Most notable of those other methods are the polynominal methods (cubic interpolation is polynominal) of which there are about two dozen standard ones, all with different purpose, quality and performance. Most should all be easy enough to implement in S|M with reasonable performance. However, since sound and graphics are obviously two entirely different fields, it's unlikely the "best" graphics interpolations are the best for sound.

Are there any (de facto) standard methods for interpolation of sound, superior to linear? Is there any research on use of polynominal (or other) interpolation of sound?

infuzion ·

mwvdlee wrote: Are there any (de facto) standard methods for interpolation of sound, superior to linear? Is there any research on use of polynominal (or other) interpolation of sound?

You're on the right track... tried searching this forum & KVR's? There are actually good discussions on both. Or just test yourself: [old link] Might be nice if you'd post some tests. 😉

trogluddite ·

The 'Developer's Toolkit' has half a dozen alternative interpolation modules from Exo, including some polynomial stuff. They certainly sound smoother to my ears than linear - but I'm not mathsy enough to have a clue how all the co-efficients etc. are derived. My guess is that, like pitch-shift algorithms, the optimal interpolation is dependent on the content of the audio to some degree - and that the most 'mathematically' accurate method is not necessarily the best sounding subjectively.

Andrew J ·

mwvdlee wrote: Are there any (de facto) standard methods for interpolation of sound, superior to linear? Is there any research on use of polynominal (or other) interpolation of sound?

Resampling filters, have a read here: http://www.mp3-tech.org/programmer/docs/resampler.pdf

mwvdlee ·

infuzion wrote: Might be nice if you'd post some tests. 😉

Well, atleast here's a visual analyzer.

It's a 440Hz sine wave at a 6000Hz sample rate played back really slowly with all the different interpolation methods from the devkit and the nearest neighbor method. Remember that the low sample rate of the sample is only used to enlarge the artifacts.

Atleast visually there are some obvious losers. Choosing the winner is a bit harder. Perhaps other wave types would provide some insight. After all, the best method is the one that reconstructs sharp edges and straight lines as well as curves 🙂

I don't know if the B-spline one is Catmull-Rom. If it is, I'd like to tweak it into the lesser-known Mitchell-Netravali, which is the one I use for my graphics programming.

MegaHurtz ·

mwvdlee wrote: Atleast visually there are some obvious losers. Choosing the winner is a bit harder. Perhaps other wave types would provide some insight. After all, the best method is the one that reconstructs sharp edges and straight lines as well as curves.

That`s the million dollar question right there, Ive been looking at this stuff for a couple of years now. And to me the sounds are`nt that different. it seems a bit like a physical impossibility to do better than liniar. simply becouse the future is an unknown factor. (noted that any sines amplitude is an unknown factor aswell, so tweaking it would require spectral manipulation). And the shape that went in there has very little resemblance to a sine. Also the motion through the array is liniar, possibly not the sound that you uncover. You`d hear the difference when the sound gets so low there`s nothing but a sine to come out. But there you instantly get the hang for a bit of distortion becouse the shape of the sound get`s more prenounced. But the hermite and optimal models are looking quite good indeed. Before yappin too much ill think ill get to giving them some field testing. Ill be back 🙂

aliasant ·

I did compare them using my drum machine build. It is probably impossible to hear the difference for a normal person using the default pitch of the recorded sound but I often pitch down quite a lot to use maybe a Clave as a 808ish bassdrum or similar and when you do that the differences are quite clear.

My personal favourites was 4th Order and B-Spline. 4th order seems to have a steeper filter so it sounds slightly "better" but it also uses a few cycles extra.

I did a quick asm optimizaion of the code part in the B-Spline and got it down from 28.5 cycles to 9.5 and since theres 2 of them codes in there it makes a small difference/voice This can probably be optimized further so if anyone feels like it.. 🙂

// 4-point, 3rd-order B-spline (x-form) Optimized by aliasant streamin frac; streamin yminus1; streamin y0; streamin y1; streamin y2; streamout out;

float c0=0; float c1=0; float c2=0; float c3=0; float c4=0; float c5=0; float ym1py1=0; float F0P5=0.5; float F0P166667=0.166667; float F0P666667=0.666667;

movaps xmm7,yminus1; movaps xmm2,y0; movaps xmm3,frac; movaps xmm5,F0P5; movaps xmm0,y1; addps xmm7,xmm0; // ***

movaps xmm6,F0P166667; mulps xmm6,xmm7; movaps xmm1,F0P666667; mulps xmm1,xmm2; addps xmm6,xmm1; // ***

movaps xmm4,xmm0; subps xmm4,yminus1; mulps xmm4,xmm5; // ***

mulps xmm7,xmm5; subps xmm7,xmm2; // ***

subps xmm2,xmm0; mulps xmm2,xmm5; movaps xmm1,y2; subps xmm1,yminus1; mulps xmm1,F0P166667; addps xmm2,xmm1; mulps xmm2,xmm3; addps xmm2,xmm7; mulps xmm2,xmm3; addps xmm2,xmm4; mulps xmm2,xmm3; addps xmm2,xmm6;

movaps out,xmm2;

/Original Code streamin frac; streamin yminus1; streamin y0; streamin y1; streamin y2; streamout out;

float c0,c1,c2,c3,c4,c5,ym1py1,F0P5=0.5;

// 4-point, 3rd-order B-spline (x-form) ym1py1 = yminus1+y1; c0 = 0.166667*ym1py1 + 0.666667*y0; c1 = F0P5*(y1-yminus1); c2 = F0P5*ym1py1 - y0; c3 = F0P5*(y0-y1) + 0.166667*(y2-yminus1); out = ((c3*frac+c2)*frac+c1)*frac+c0;

infuzion ·

aliasant wrote: I did a quick asm optimizaion of the code part in the B-Spline and got it down from 28.5 cycles to 9.5

9.5 cycles? That would be impossible, since you have a string of math that is longer than 9 in a row, plus all the other movaps & maths before that. Though you did do a good job on optimization! 😇

aliasant ·

infuzion wrote: aliasant wrote: I did a quick asm optimizaion of the code part in the B-Spline and got it down from 28.5 cycles to 9.5

9.5 cycles? That would be impossible, since you have a string of math that is longer than 9 in a row, plus all the other movaps & maths before that. Though you did do a good job on optimization! 😇

Well. .lol Thats the resulh I get on my PC. I checked several times. What results do you get?

mwvdlee ·

infuzion wrote: aliasant wrote: I did a quick asm optimizaion of the code part in the B-Spline and got it down from 28.5 cycles to 9.5

9.5 cycles? That would be impossible, since you have a string of math that is longer than 9 in a row, plus all the other movaps & maths before that. Though you did do a good job on optimization! 😇

AFAIK, cycles as used in the old days no longer apply and modern CPU's can do multiple simultaneous instructions in one cycle as long as they're not dependant upon eachother's results (and even them some CPU's can use predictive models). What I'm wondering more is how he actually measured the number of cycles. Is that built into S|M and did I miss it?

trogluddite ·

CPU Analyser

aliasant ·

trogluddite wrote: CPU Analyser

That one doesnt really work on my machine. Resuls are quite weird but they are quite weird with my own too but more consistent. 😕 My cycles dont really mean anyting for anyone else but I think the differences between my results can give others at least a hint.

flamingRedDingo ·

9.5 cycles *is* in fact, possible for a series of 9 operations...

Modern cpu technology is superscalar. More than one operation is often performed per "cycle" - so even WRT a single core, you can't count cycles to determine the # of operations...

CPU cycle counting is useless w/ modern CPU technology. It's an abstract indicator at best, and most of the time, the results are so incredibly misleading in the general case as to be worse than useless.

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.