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

Bounded note-retention kernel over a MIDI event stream. More...

#include <latch.hpp>

Public Member Functions

constexpr Latch (LatchSpec spec={}) noexcept
constexpr bool valid () const noexcept
constexpr LatchSpec spec () const noexcept
MidiUtilityProcessReport process (const MidiBuffer &input, MidiBuffer &output) noexcept
MidiUtilityProcessReport flush (MidiBuffer &output) noexcept
 Release every note the latch still owns.
MidiUtilityProcessReport reset (MidiBuffer &output) noexcept
MidiUtilityProcessReport replace_spec (LatchSpec spec, MidiBuffer &output) noexcept
 Swap the retention mode.
bool empty () const noexcept
std::uint32_t owned_depth (std::uint8_t channel, std::uint8_t note) const noexcept
 Number of note-offs the latch still owes for channel/note.

Static Public Member Functions

static constexpr MidiUtilityContract contract () noexcept
static constexpr bool valid_spec (LatchSpec spec) noexcept

Static Public Attributes

static constexpr std::size_t kKeySpace = 16 * 128

Detailed Description

Bounded note-retention kernel over a MIDI event stream.

The kernel owns every note it retains: a retained note-on is forwarded once and its authored note-off is swallowed, so the matching note-off is emitted later by the latch itself. Retention depth is counted per (channel, note) key, so repeated attacks on one key never leak or double-release. The key space is the whole 16x128 MIDI grid, so retention never overflows and the kernel needs no dynamic allocation on any path.

Constructor & Destructor Documentation

◆ Latch()

pulp::midi::Latch::Latch ( LatchSpec spec = {})
inlineexplicitconstexprnoexcept

Member Function Documentation

◆ contract()

constexpr MidiUtilityContract pulp::midi::Latch::contract ( )
inlinestaticconstexprnoexcept

◆ empty()

bool pulp::midi::Latch::empty ( ) const
inlinenoexcept

◆ flush()

MidiUtilityProcessReport pulp::midi::Latch::flush ( MidiBuffer & output)
inlinenoexcept

Release every note the latch still owns.

Used on transport discontinuities and when the caller tears the kernel down.

◆ owned_depth()

std::uint32_t pulp::midi::Latch::owned_depth ( std::uint8_t channel,
std::uint8_t note ) const
inlinenoexcept

Number of note-offs the latch still owes for channel/note.

◆ process()

MidiUtilityProcessReport pulp::midi::Latch::process ( const MidiBuffer & input,
MidiBuffer & output )
inlinenoexcept

◆ replace_spec()

MidiUtilityProcessReport pulp::midi::Latch::replace_spec ( LatchSpec spec,
MidiBuffer & output )
inlinenoexcept

Swap the retention mode.

The pending mode is applied only once every owned note has been released, so a mode change can never orphan a sounding note.

◆ reset()

MidiUtilityProcessReport pulp::midi::Latch::reset ( MidiBuffer & output)
inlinenoexcept

◆ spec()

LatchSpec pulp::midi::Latch::spec ( ) const
inlineconstexprnoexcept

◆ valid()

bool pulp::midi::Latch::valid ( ) const
inlineconstexprnoexcept

◆ valid_spec()

constexpr bool pulp::midi::Latch::valid_spec ( LatchSpec spec)
inlinestaticconstexprnoexcept

Member Data Documentation

◆ kKeySpace

std::size_t pulp::midi::Latch::kKeySpace = 16 * 128
staticconstexpr

The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/midi/include/pulp/midi/latch.hpp