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

Reassembler state machine for UMP Type-0x3 sysex7 packet streams. More...

#include <ump_sysex7_reassembler.hpp>

Public Types

enum class  Status {
  single_packet , start , continued , ended ,
  dropped
}
 Classification of the most recently consumed packet. More...
enum class  DropReason {
  none , orphan , reserved_status , invalid_size ,
  high_bit_payload , overflow , nested_start , reset
}
 Why the last packet was dropped (or why a partial message was reset). More...

Public Member Functions

 UmpSysex7Reassembler (std::size_t maximum_payload_bytes=default_maximum_payload_bytes)
Status feed_packet (std::uint32_t word0, std::uint32_t word1, Sysex7EmitFn emit, void *user) noexcept
 Feed a single 2-word UMP packet through the state machine.
bool in_progress () const noexcept
 True when an in-progress sysex is open (a 0x1 start packet has been seen and no 0x3 end packet has closed it yet).
std::size_t partial_size (std::uint8_t group=0) const noexcept
 Current accumulated payload size in bytes (0 when idle).
void reserve (std::size_t worst_case_bytes)
 Reserve worst-case payload capacity to avoid allocations in the hot path.
std::size_t maximum_payload_bytes () const noexcept
DropReason last_drop_reason () const noexcept
void reset () noexcept
 Drop any in-progress sysex without emitting.

Static Public Attributes

static constexpr std::size_t default_maximum_payload_bytes = 64u * 1024u

Detailed Description

Reassembler state machine for UMP Type-0x3 sysex7 packet streams.

Per-stream — see "Thread-safety" in the file header.

Member Enumeration Documentation

◆ DropReason

Why the last packet was dropped (or why a partial message was reset).

This is deliberately separate from Status so existing callers that only distinguish emitted versus dropped packets remain source compatible while diagnostics can fail closed.

Enumerator
none 
orphan 
reserved_status 
invalid_size 
high_bit_payload 
overflow 
nested_start 
reset 

◆ Status

Classification of the most recently consumed packet.

Enumerator
single_packet 

Single-packet sysex (status nibble 0x0).

The emit callback fired with the complete payload.

start 

Start packet (status nibble 0x1).

Accumulator is now armed; the emit callback has NOT fired yet.

continued 

Continue packet (status nibble 0x2) appended to an armed accumulator.

The emit callback has NOT fired yet.

ended 

End packet (status nibble 0x3) closed an armed accumulator.

The emit callback fired with the complete payload.

dropped 

Continue / end without a preceding start, OR a packet whose status nibble is neither 0x0/0x1/0x2/0x3.

The accumulator is untouched; the callback did NOT fire.

Constructor & Destructor Documentation

◆ UmpSysex7Reassembler()

pulp::midi::UmpSysex7Reassembler::UmpSysex7Reassembler ( std::size_t maximum_payload_bytes = default_maximum_payload_bytes)
inlineexplicit

Member Function Documentation

◆ feed_packet()

Status pulp::midi::UmpSysex7Reassembler::feed_packet ( std::uint32_t word0,
std::uint32_t word1,
Sysex7EmitFn emit,
void * user )
inlinenoexcept

Feed a single 2-word UMP packet through the state machine.

Caller must ensure the packet is actually a Type-0x3 (sysex7) packet — i.e. (word0 >> 28) & 0x0F == 0x3. Passing a non-0x3 packet is a programmer error; the reassembler does not validate the message type itself because callers already need that nibble for dispatch / cursor-advance and re-checking it here would be redundant work in the hot path.

emit is invoked at most once per call, only when this packet completes a logical sysex (status 0x0 or 0x3). user is passed through verbatim — keep it lightweight to preserve RT-safety.

◆ in_progress()

bool pulp::midi::UmpSysex7Reassembler::in_progress ( ) const
inlinenoexcept

True when an in-progress sysex is open (a 0x1 start packet has been seen and no 0x3 end packet has closed it yet).

◆ last_drop_reason()

DropReason pulp::midi::UmpSysex7Reassembler::last_drop_reason ( ) const
inlinenoexcept

◆ maximum_payload_bytes()

std::size_t pulp::midi::UmpSysex7Reassembler::maximum_payload_bytes ( ) const
inlinenoexcept

◆ partial_size()

std::size_t pulp::midi::UmpSysex7Reassembler::partial_size ( std::uint8_t group = 0) const
inlinenoexcept

Current accumulated payload size in bytes (0 when idle).

◆ reserve()

void pulp::midi::UmpSysex7Reassembler::reserve ( std::size_t worst_case_bytes)
inline

Reserve worst-case payload capacity to avoid allocations in the hot path.

Safe to call at port-open / prepare() time. The single- packet scratch buffer is also prepared here so interleaved complete sysex packets do not allocate while another sysex is open. This sets the exact admission bound and discards any current partial streams; call it during non-RT configuration.

◆ reset()

void pulp::midi::UmpSysex7Reassembler::reset ( )
inlinenoexcept

Drop any in-progress sysex without emitting.

Use on port-close or when a transport-level reset is observed (e.g. CoreMIDI endpoint reconnect).

Member Data Documentation

◆ default_maximum_payload_bytes

std::size_t pulp::midi::UmpSysex7Reassembler::default_maximum_payload_bytes = 64u * 1024u
staticconstexpr

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