Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
ump_endpoint.hpp
Go to the documentation of this file.
1#pragma once
2
3// UMP Endpoint — abstract handle to a MIDI 2.0 UMP source/destination.
4//
5// A UMP endpoint is a single bidirectional logical port — on CoreMIDI 2.0 it
6// wraps a `MIDIEndpointRef`, on Windows it wraps a MIDIEndpointConnection
7// (WinRT MIDI 2.0), on Linux it wraps an ALSA Rawmidi UMP node. The
8// Pulp surface is intentionally OS-agnostic: callers see UmpPacket in,
9// UmpPacket out.
10//
11// Design notes:
12// - Endpoints are owned by a UmpSession. Calling code never news them
13// directly; it asks the session for one (or registers a virtual one).
14// - The receive callback fires on whatever thread the OS chose for
15// MIDI delivery (CoreMIDI: a dedicated MIDIClient thread; WinRT: the
16// UMP callback thread). Callers must not block.
17// - Send is non-blocking and lock-free where the OS allows it.
18// - Endpoints expose a stable string id (CoreMIDI unique-id; WinRT
19// EndpointDeviceId; ALSA card:device) so callers can persist a
20// selection across runs.
21//
22// Versus the older `MidiInput` / `MidiOutput` pair: those operate on
23// MIDI 1.0 byte streams (with the WinRT/CoreMIDI backends translating
24// internally). `UmpEndpoint` is the UMP-native surface; both layers
25// will coexist while Pulp finishes the UMP migration.
26
27#include <pulp/midi/ump.hpp>
28
29#include <cstdint>
30#include <functional>
31#include <string>
32#include <vector>
33
34namespace pulp::midi {
35
41 bool can_receive = false; // we can read UMP packets from it
42 bool can_send = false; // we can write UMP packets to it
43};
44
50 std::string id;
52 std::string name;
57 bool is_virtual = false;
59};
60
64using UmpReceiveCallback = std::function<void(const UmpPacket& packet,
65 double timestamp_sec)>;
66
70public:
71 virtual ~UmpEndpoint() = default;
72
74 virtual const UmpEndpointInfo& info() const noexcept = 0;
75
83
88 virtual bool send(const UmpPacket& packet) = 0;
89
92 virtual bool is_open() const noexcept = 0;
93};
94
95} // namespace pulp::midi
Polymorphic endpoint handle.
Definition ump_endpoint.hpp:69
virtual bool send(const UmpPacket &packet)=0
Send a UMP packet.
virtual bool is_open() const noexcept=0
True iff the endpoint is currently usable (port connected, virtual endpoint live).
virtual const UmpEndpointInfo & info() const noexcept=0
Snapshot of the endpoint's static metadata.
virtual void set_receive_callback(UmpReceiveCallback cb)=0
Register the receive callback.
virtual ~UmpEndpoint()=default
Definition custom_node_events.hpp:26
std::function< void(const UmpPacket &packet, double timestamp_sec)> UmpReceiveCallback
Receive callback.
Definition ump_endpoint.hpp:64
Direction the endpoint exposes.
Definition ump_endpoint.hpp:40
bool can_send
Definition ump_endpoint.hpp:42
bool can_receive
Definition ump_endpoint.hpp:41
Static description of an endpoint discovered on the system or registered virtually.
Definition ump_endpoint.hpp:47
std::string name
Human-readable display name.
Definition ump_endpoint.hpp:52
bool is_virtual
True if this endpoint exists only in-process (registered via UmpSession::register_virtual_endpoint).
Definition ump_endpoint.hpp:57
UmpEndpointDirection direction
Definition ump_endpoint.hpp:58
std::string id
Stable identifier (CoreMIDI unique-id as decimal, WinRT EndpointDeviceId, virtual endpoint name,...
Definition ump_endpoint.hpp:50
Definition ump.hpp:84