[sldev] Wind Sound CPU usage. (patch-4)

Jason Giglio gigstaggart at gmail.com
Thu Mar 6 18:20:04 PST 2008


Callum Lerwick wrote:
  > Bleh. You still shouldn't need to interpolate every sample. What is the
> block size? Limit the inner loop to N samples, where N is a suitable
> "control rate", then put another loop around it that recalculates the
> filter coefficients and loops until the buffer is full.

We don't anymore.  We only interpolate frequency if the delta is more 
than 200 hertz now.  Interpolation of the gains isn't as expensive 
computationally, since the frequency interpolation is what requires 
recalculating the filter coefficients in the inner loop.

> And we may be able find a faster filter design, actually the existing
> one appears pretty simple in the inner loop, but cos()/sqrt() are
> killers. Establishing a control rate might make this manageable. But it
> is not documented what the filter actually *is*... Sounds like a
> bandpass filter. 24db/oct? I suppose I can fire up baudline and see...

Well the cos/sqrt are only called in the inner loop when we have a delta 
now, so if you are standing still or flying at a steady speed, it's 
bypassed most of the time.

> The final clip check irks me. If you're clipping, you've failed anyway.
> The generator needs to be bounded to not clip anyway. Nuke clipSample(),
> which will make any clipping even more noticeable (integer wraparound),
> and tweak the scaling factor down (the 32768.f) until it stops clipping.
> That will save us some branches.

Actually... now that I think about it, we are casting to an S16 (or 
whatever MIXBUFFERFORMAT is, but S16 most of the time) before passing it 
to clipSample, so clipSample can never actually accomplish anything 
anyway, unless it's not an S16, in which case it's inappropriate to 
clamp it to 32768 anyway, right?

> The conversion code I wrote for something else is using 32767, one less,
> but then the float is pre-clipped to -1/+1. Since this is a resonant
> filter we're dealing with, its possible for the output samples to exceed
> the range of the input samples, so it may need to be tweaked down a bit
> more...

Aimee has worked around this issue by scaling the initial white noise 
input down to [-0.25, 0.25]... this prevents clipping under most normal 
circumstances.

And yes as far as I can tell it's a bandpass filter.

-Jason


More information about the SLDev mailing list