Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::audio::LoadClockRatio Struct Reference

Converts a span of monotonic clock ticks to nanoseconds. More...

#include <load_measurer.hpp>

Public Member Functions

constexpr std::int64_t to_ns (std::uint64_t ticks) const noexcept
 Nanoseconds in a span of ticks, saturating at INT64_MAX.

Static Public Member Functions

static constexpr LoadClockRatio reduced (std::uint64_t numer, std::uint64_t denom) noexcept
 numer/denom reduced by their GCD.
static LoadClockRatio host () noexcept
 The running platform's timebase. Not for the audio thread.

Public Attributes

std::uint64_t numer = 1
std::uint64_t denom = 1

Friends

constexpr bool operator== (const LoadClockRatio &, const LoadClockRatio &)=default

Detailed Description

Converts a span of monotonic clock ticks to nanoseconds.

The ratio is reduced once, off the audio thread, so converting a span is one 64-bit multiply and divide. host() reads the platform timebase: mach_timebase_info() on Apple (125/3 on M1, 1/1 on later chips), and 1/1 elsewhere, where the ticks are already steady_clock nanoseconds.

Member Function Documentation

◆ host()

LoadClockRatio pulp::audio::LoadClockRatio::host ( )
inlinestaticnoexcept

The running platform's timebase. Not for the audio thread.

◆ reduced()

constexpr LoadClockRatio pulp::audio::LoadClockRatio::reduced ( std::uint64_t numer,
std::uint64_t denom )
inlinestaticconstexprnoexcept

numer/denom reduced by their GCD.

A zero numerator or denominator names an unavailable clock, which converts every span to 0.

◆ to_ns()

std::int64_t pulp::audio::LoadClockRatio::to_ns ( std::uint64_t ticks) const
inlineconstexprnoexcept

Nanoseconds in a span of ticks, saturating at INT64_MAX.

◆ operator==

bool operator== ( const LoadClockRatio & ,
const LoadClockRatio &  )
friend

Member Data Documentation

◆ denom

std::uint64_t pulp::audio::LoadClockRatio::denom = 1

◆ numer

std::uint64_t pulp::audio::LoadClockRatio::numer = 1

The documentation for this struct was generated from the following file: