tags:

views:

25

answers:

2

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?

+1  A: 

Just two thoughts:

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

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

amrox