CPU Cycle Counter Formula in AudioStream

Status
Not open for further replies.

chipaudette

Well-known member
I love how the Audio library lets you see what fraction of the processor is being consumed by different blocks in your audio processing chain. But, in looking at the formula, I don't understand how the calculation is done...

From AudioStream.h, I see this formula:

#define CYCLE_COUNTER_APPROX_PERCENT(n) (((n) + (F_CPU / 32 / AUDIO_SAMPLE_RATE * AUDIO_BLOCK_SAMPLES / 100)) / (F_CPU / 16 / AUDIO_SAMPLE_RATE * AUDIO_BLOCK_SAMPLES / 100))

I understand the scaling by the sample rate and block size. The part that I don't understand is the bit in red. Why is there this additive term?

Chip
 
Status
Not open for further replies.
Back
Top