load.h
LoadMeasurer: how much of the audio deadline a DSP is using.
#include <sonore/load.h>- 1type
- Guides: Getting started, MIDI and MPE
On this page
Design notes
Why this belongs in THIS SDK in particular
A hand-written plugin is profiled by the person who wrote it. A generated one has no such person. The DSP in a Sonorie plugin was written by a model that has never heard it run, cannot know what a 128-frame block at 48 kHz costs, and will happily emit a 64-stage filter bank inside a per-sample loop.
So the plugin has to be able to say so itself.
What "load" means here
The fraction of a block's REAL-TIME BUDGET spent computing it. A block of 128 frames at 48 kHz must be finished within 2.67 ms, because that is when the next one is due. Taking 1.33 ms is a load of 0.5; taking 2.67 ms is 1.0 and the next block is already late.
This is not the same as "percent of one CPU core" and the difference matters: a host running twenty plugins gives each of them the same deadline, so a load of 0.5 means this plugin alone would fill half the budget of a machine doing nothing else.
Cost
Two clock reads per block and a handful of arithmetic. steady_clock on Windows is QueryPerformanceCounter and on Linux a vDSO read of the monotonic clock; neither takes a lock or enters the kernel on any machine this will run on. At a 128-frame block that is two reads per 2.67 ms, which is not measurable against the audio itself -- confirmed rather than assumed, in the tests.
Types 1
Measures the time spent in a process callback against that block's deadline.
Written from the audio thread and read from any other, so the published values are atomics. They are stored with relaxed ordering: a reader is drawing a meter, and a meter that is one block stale is not wrong in any way a person can see.