Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Classes | Namespaces
audio_budget.hpp File Reference

Audio callback cycle budget tracker. More...

#include <cstdint>
#include <cstddef>
Include dependency graph for audio_budget.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  sbl::profiling::AudioBudget
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs functionality.
 
namespace  sbl::profiling
 CPU load monitoring.
 

Detailed Description

Audio callback cycle budget tracker.

Measures per-block CPU cycle consumption in audio callbacks using the DWT cycle counter. Tracks average (EWMA), peak, min, overrun count, and a per-block CPU load histogram (11 buckets, 10% each).

Gated behind SBL_PROFILING_ENABLED. When the define is absent, all methods compile to no-ops and the class has zero data members – no binary impact whatsoever.

Usage: static sbl::profiling::AudioBudget budget; budget.init(48000, 48, 480'000'000);

void audio_callback(int32_t* tx, const int32_t* rx, uint16_t frames) { budget.on_block_start(); // ... DSP ... budget.on_block_end(); }

// In control loop: budget.avg_load() // [0.0, 1.0+] budget.peak_load() // worst-case since last reset budget.overruns() // count of callbacks that exceeded budget

Definition in file audio_budget.hpp.