Forum Rule: Always post complete source code & details to reproduce any issue!
-
CPU Cycle Counter Formula in AudioStream
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
-
Senior Member

Originally Posted by
chipaudette
Why is there this additive term?
It rounds to the nearest integer. Or at least it did in the days when AUDIO_SAMPLE_RATE was expressed as an integer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules