Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::midi::MonotonicMidiClock Class Reference

Monotonic timestamp source for MIDI input events, measured in seconds from a base captured when the port opened. More...

#include <monotonic_timestamp.hpp>

Public Types

using clock = std::chrono::steady_clock

Public Member Functions

void reset (clock::time_point now)
 Capture the open-time base. Call once when the port opens.
void reset ()
double seconds_since_open (clock::time_point now) const
 Seconds elapsed since the captured base.
double seconds_since_open () const
bool has_base () const

Detailed Description

Monotonic timestamp source for MIDI input events, measured in seconds from a base captured when the port opened.

MidiEvent::timestamp is documented as "absolute time in seconds" (buffer.hpp). The Windows backend reports seconds-since-open via QPC (winmidi_device.cpp) and CoreMIDI reports host-time seconds; the Linux ALSA raw-midi path previously hardcoded 0.0, losing all timing. This helper gives the ALSA path the same seconds-since-open semantics as Windows using std::chrono::steady_clock, which is guaranteed monotonic.

The now-taking overloads are pure, so the conversion is unit-testable with synthetic time points without depending on the wall clock.

Member Typedef Documentation

◆ clock

using pulp::midi::MonotonicMidiClock::clock = std::chrono::steady_clock

Member Function Documentation

◆ has_base()

bool pulp::midi::MonotonicMidiClock::has_base ( ) const
inline

◆ reset() [1/2]

void pulp::midi::MonotonicMidiClock::reset ( )
inline

◆ reset() [2/2]

void pulp::midi::MonotonicMidiClock::reset ( clock::time_point now)
inline

Capture the open-time base. Call once when the port opens.

◆ seconds_since_open() [1/2]

double pulp::midi::MonotonicMidiClock::seconds_since_open ( ) const
inline

◆ seconds_since_open() [2/2]

double pulp::midi::MonotonicMidiClock::seconds_since_open ( clock::time_point now) const
inline

Seconds elapsed since the captured base.

Returns 0 before the first reset() so an un-opened source never reports a bogus large value.


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