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

Lock-free panic request and output-note state for one Processor. More...

#include <panic.hpp>

Public Member Functions

void request (PanicMode mode) noexcept
 Raise a panic request from any thread.
bool take (PanicMode &mode) noexcept
 Consume the pending request (audio thread). False when none is pending.
bool carrying () const noexcept
 A panic whose MIDI did not fit in one block and is still being sent.
std::uint64_t deferred_events () const noexcept
 Total events that did not fit the MIDI output buffer in some block and were deferred to a later one.
bool pending () const noexcept
void attach (bool midi_out) noexcept
 Adapter wiring, off the audio thread.
void detach () noexcept
PanicCapabilities capabilities () const noexcept
void observe_midi_out (const midi::MidiBuffer &midi_out) noexcept
 Track the notes the plug-in sent downstream (audio thread, after process()).
const midi::MidiKeyboardState & emitted_notes () const noexcept
 Notes currently believed held downstream.
PanicOutcome emit_midi (PanicMode mode, midi::MidiBuffer &out, std::int32_t sample_offset=0) noexcept
 Write the panic into out (audio thread): note-offs for the held notes, then the channel messages for mode, all at sample_offset.
bool take_carry (PanicMode &mode) noexcept
 Mode of a panic still being sent (audio thread).
void restart_messages () noexcept
 Start the message sequence from the top (a new request arrived).

Detailed Description

Lock-free panic request and output-note state for one Processor.

Created off the audio thread (Processor::panic_state()); the audio thread only touches the atomics and the note tracker.

Member Function Documentation

◆ attach()

void pulp::format::PanicState::attach ( bool midi_out)
inlinenoexcept

Adapter wiring, off the audio thread.

midi_out states whether the adapter can deliver MIDI output.

◆ capabilities()

PanicCapabilities pulp::format::PanicState::capabilities ( ) const
inlinenoexcept

◆ carrying()

bool pulp::format::PanicState::carrying ( ) const
inlinenoexcept

A panic whose MIDI did not fit in one block and is still being sent.

◆ deferred_events()

std::uint64_t pulp::format::PanicState::deferred_events ( ) const
inlinenoexcept

Total events that did not fit the MIDI output buffer in some block and were deferred to a later one.

Readable from any thread; a persistently rising value means the adapter's per-block MIDI buffer is too small for the panic (a full panic is up to midi::kMaxPanicMessages events plus one note-off per held note).

◆ detach()

void pulp::format::PanicState::detach ( )
inlinenoexcept

◆ emit_midi()

PanicOutcome pulp::format::PanicState::emit_midi ( PanicMode mode,
midi::MidiBuffer & out,
std::int32_t sample_offset = 0 )
inlinenoexcept

Write the panic into out (audio thread): note-offs for the held notes, then the channel messages for mode, all at sample_offset.

Appends only; it never clears out. If out fills, what was written stays written and the rest is remembered: notes not yet ended stay in the tracker, and the channel messages resume at the first one not written. The next service_panic() call continues from there.

◆ emitted_notes()

const midi::MidiKeyboardState & pulp::format::PanicState::emitted_notes ( ) const
inlinenoexcept

Notes currently believed held downstream.

◆ observe_midi_out()

void pulp::format::PanicState::observe_midi_out ( const midi::MidiBuffer & midi_out)
inlinenoexcept

Track the notes the plug-in sent downstream (audio thread, after process()).

Only meaningful when the adapter has MIDI output.

◆ pending()

bool pulp::format::PanicState::pending ( ) const
inlinenoexcept

◆ request()

void pulp::format::PanicState::request ( PanicMode mode)
inlinenoexcept

Raise a panic request from any thread.

A pending release request is upgraded by an immediate one, never the reverse.

◆ restart_messages()

void pulp::format::PanicState::restart_messages ( )
inlinenoexcept

Start the message sequence from the top (a new request arrived).

◆ take()

bool pulp::format::PanicState::take ( PanicMode & mode)
inlinenoexcept

Consume the pending request (audio thread). False when none is pending.

◆ take_carry()

bool pulp::format::PanicState::take_carry ( PanicMode & mode)
inlinenoexcept

Mode of a panic still being sent (audio thread).


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