Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
monotonic_timestamp.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4
5namespace pulp::midi {
6
20public:
21 using clock = std::chrono::steady_clock;
22
24 void reset(clock::time_point now) {
25 base_ = now;
26 has_base_ = true;
27 }
28 void reset() { reset(clock::now()); }
29
32 double seconds_since_open(clock::time_point now) const {
33 if (!has_base_) return 0.0;
34 return std::chrono::duration<double>(now - base_).count();
35 }
36 double seconds_since_open() const { return seconds_since_open(clock::now()); }
37
38 bool has_base() const { return has_base_; }
39
40private:
41 clock::time_point base_{};
42 bool has_base_ = false;
43};
44
45} // namespace pulp::midi
Monotonic timestamp source for MIDI input events, measured in seconds from a base captured when the p...
Definition monotonic_timestamp.hpp:19
double seconds_since_open(clock::time_point now) const
Seconds elapsed since the captured base.
Definition monotonic_timestamp.hpp:32
double seconds_since_open() const
Definition monotonic_timestamp.hpp:36
void reset(clock::time_point now)
Capture the open-time base. Call once when the port opens.
Definition monotonic_timestamp.hpp:24
bool has_base() const
Definition monotonic_timestamp.hpp:38
std::chrono::steady_clock clock
Definition monotonic_timestamp.hpp:21
void reset()
Definition monotonic_timestamp.hpp:28
Definition custom_node_events.hpp:26