|
| | AudioProcessLoadMeasurer () noexcept |
| | Reads the platform timebase once, here, so begin() and end() never query it.
|
| | AudioProcessLoadMeasurer (LoadClockRatio ratio) noexcept |
| | Uses ratio to convert clock ticks to nanoseconds.
|
| LoadClockRatio | clock_ratio () const noexcept |
| | The tick-to-nanosecond ratio captured at construction.
|
| void | begin (int num_frames, float sample_rate) noexcept |
| | Call at the start of the audio callback.
|
| void | end () noexcept |
| | Call at the end of the audio callback.
|
| float | load () const noexcept |
| | Current smoothed CPU load (0.0 = idle, 1.0 = full buffer, >1.0 = overrun).
|
| float | peak_load () const noexcept |
| | Peak load since last reset.
|
| float | last_load () const noexcept |
| | Last raw load sample.
|
| std::int64_t | last_elapsed_ns () const noexcept |
| | Most recent measured callback duration, in nanoseconds (0 before the first valid window).
|
| std::uint64_t | callback_count () const noexcept |
| | Number of valid callback windows measured since the last reset.
|
| std::uint64_t | overload_count () const noexcept |
| | Number of valid callback windows whose raw load reached the overload threshold.
|
| AudioProcessLoadSnapshot | snapshot () const noexcept |
| | Latest telemetry snapshot. Safe to poll from UI/diagnostic threads.
|
| void | reset_peak () noexcept |
| | Reset peak load tracker.
|
| void | reset () noexcept |
| | Reset all state.
|
| void | set_smoothing (float alpha) noexcept |
| | Set smoothing factor (0 = no smoothing, 1 = no averaging).
|
| void | set_overload_threshold (float load) noexcept |
| | Set the raw-load threshold that increments overload_count().
|
Measures the CPU load of an audio processing callback.
Call begin() at the start and end() at the end of your process() method. The load is the fraction of available time consumed by processing.
The audio-thread hot path performs fixed arithmetic and relaxed atomic stores only. It does not allocate, lock, or block. Polling threads may read load(), peak_load(), or snapshot() concurrently; multi-field snapshots are latest-value telemetry and may mix adjacent callbacks.
load_measurer_.begin(buffer.num_frames(), sample_rate_);
load_measurer_.end();
float cpu = load_measurer_.load();
}
Non-owning view over multi-channel audio sample data.
Definition buffer.hpp:30