about: Poly-Ana

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

you could gain some improvement by using a tmp variable for fr^2

fr2 = fr*fr
warp = fr*0.696 + fr2*0.225 + fr*fr2*0.079

that way the square is only computed once, and can be done in advance of being needed. However, the performance gain will be slight...

DSP
Image

Post

if you can do something else between calculating fr2 and warp that might be a good idea, so that you don't have to wait for fr2 to be calculated before calculating warp.

Post

..like put the kettle on for a nice brew?
Image

Post

Something like that, yes :)

Post

funny the horner scheme should come up on this thread as well, because I fought with it's related optimisations recently as well. I actually stopped doing it to some extent because I wasn't seeing impact on performance.

Hence, I would presume compilers are actually fairly intelligent in this already (at least VC++ is), and they even handle the temp variable optimisations duncanparsons suggested internally.

..at least to some extent. I have limited tools to profile these things.

Post

It'll be faster than powf()! That's all I know.

Haven't tested this yet because I've needed a few days with my head out of the engine. But I plan to try it soon and will let you know. :D

Post

duncanparsons wrote:..like put the kettle on for a nice brew?
LOL! :)

Post

OK, two weeks later and after adding a ton of new GUI features it's finally time to get my head back into the sound engine again.

So, sambean, I tried your algo and couldn't figure out how to get it to work. (Didn't spend much time on it yet but thought I'd just ask...)

How would I use your algo to replace powf in this line?...

fFreq = 440.f * pow( 2.0f, fNote);

Post

AdmiralQuality wrote:OK, two weeks later and after adding a ton of new GUI features it's finally time to get my head back into the sound engine again.

So, sambean, I tried your algo and couldn't figure out how to get it to work. (Didn't spend much time on it yet but thought I'd just ask...)

How would I use your algo to replace powf in this line?...

fFreq = 440.f * pow( 2.0f, fNote);
just looked at sambeans code, i might be wrong:

looks like your fNote is the note offset based on 440hz, so its just

fFreq = fastishP2F(fNote) * 440.0f;

of course, inline fastishP2F for speed.

Post

VladimirDimitrievich wrote:just looked at sambeans code, i might be wrong:

looks like your fNote is the note offset based on 440hz, so its just

fFreq = fastishP2F(fNote) * 440.0f;

of course, inline fastishP2F for speed.
Nope, that's what I tried originally.

Post

Oh wait, I got it now... needed to remove that line. Also I had made some changes that I forgot to put back.

Seems to be working!! Testing and evaluating...

Post

I'm actually having this problem in my synth right now. It really, really doesn't seem to be linear. Earlier in this thread someone mentioned...

2*sin((2/rate) * frequency)

Is that the key?

On MusicDSP there's a filter with this:

f = 2.0f*(float)sin(M_PI*freq/samplerate);

Post

mistertoast wrote:I'm actually having this problem in my synth right now. It really, really doesn't seem to be linear. Earlier in this thread someone mentioned...

2*sin((2/rate) * frequency)

Is that the key?

On MusicDSP there's a filter with this:

f = 2.0f*(float)sin(M_PI*freq/samplerate);
What kind of filter mistertoast? Poly's is an IIR. All I know for sure is it's VERY linear at the low end, but gets more and more out of tune as you raise the cutoff. Poly-Ana's internal oversampling almost completely cures this issue when running at 8X. But even at 4X the filter resonance is noticeably out of tune (unless you stick to a small range).

Just in case anyone is confused, we kind of have two subjects going here: 1. Scaling cutoff/resonant frequency in an IIR so it will track notes accurately. 2. Optimizing pitch to frequency conversion.

Post

I'm also using an IIR. And I see now that several of the filters on MusicDSP have that line of code. Some approximate it, but warn of tuning error towards Nyquist. The 2*sin(M_PI*freq/sr) is the "correct" method. I just don't know why. I'll look for a derivation.

My only remaining problem is I don't happen to have the freq of my current note in Hz, but I should be able to get that going reasonably easily.

I'm going to assume this mystery is solved.

Post

mistertoast wrote:I'm also using an IIR. And I see now that several of the filters on MusicDSP have that line of code. Some approximate it, but warn of tuning error towards Nyquist. The 2*sin(M_PI*freq/sr) is the "correct" method. I just don't know why. I'll look for a derivation.

My only remaining problem is I don't happen to have the freq of my current note in Hz, but I should be able to get that going reasonably easily.

I'm going to assume this mystery is solved.
Hmmm, I'll give it a try then, but it seems like it'll be stronger than what I expect. Maybe that's just because, again, I only deal with the low end of the curve. (Obviously I'm programming from the gut here. But it got me this far! ;) )

And yes, a more optimal aproximation would be nice. Also would be nice if this could be built into the pitch to frequency calc! i.e. in a special case version just for the filter.

Curious, what form of frequency DO you have for your current note?

Post Reply

Return to “DSP and Plugin Development”