开发者

Audio -- How much performance improvement can I expect from from reducing function calls by using buffers?

I'm working on an audio-intensive app for the iPhone. I'm currently calling a number of different functions for each sample I need to calculate. For example, I have an envelope class. When I calculate a sample, I do something like:

sampleValue = oscilator->tic() * envelope->tic();

But I could also do something like:

for(int i = 0; i < bufferLength; i++){
   buffer[i] = oscilatorBuffer[i] * evelopeBuffer[i];
}
开发者_如何转开发

I know the second will be more efficient, but don't know by how much. Are function calls expensive enough that I'd be crazy not to use buffers if I care event a tiny bit about performance?


Just two thoughts:

  1. Function calls are very cheap.
  2. When talking about performance, nothing beats an experiment.


You could make all you current functions inline, and compare performance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜