Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::midi::Humanize< MaximumPendingAttacks > Class Template Reference

MaximumPendingAttacks bounds how many attacks can sit in the jitter window at once. More...

#include <humanize.hpp>

Public Member Functions

constexpr Humanize (HumanizeSpec spec={}) noexcept
constexpr bool valid () const noexcept
constexpr HumanizeSpec spec () const noexcept
MidiUtilityProcessReport process (const MidiBuffer &input, MidiBuffer &output, timebase::SamplePosition block_start, std::int32_t block_samples) noexcept
MidiUtilityProcessReport flush (MidiBuffer &output, timebase::SamplePosition block_start) noexcept
 Emit every attack still waiting in the jitter window.
MidiUtilityProcessReport reset (MidiBuffer &output, timebase::SamplePosition block_start) noexcept
MidiUtilityProcessReport replace_spec (HumanizeSpec spec, MidiBuffer &output, timebase::SamplePosition block_start) noexcept
bool update_spec_for_future_attacks (HumanizeSpec spec) noexcept
 Change the spec used to schedule future attacks without disturbing attacks already materialized in the pending queue.
bool empty () const noexcept

Static Public Member Functions

static constexpr MidiUtilityContract contract () noexcept
static constexpr bool valid_spec (HumanizeSpec spec) noexcept
static constexpr bool is_identity (HumanizeSpec spec) noexcept
 True when the spec cannot change any event, which is the kernel's declared bypass identity.
static std::int64_t jittered_position (HumanizeSpec spec, std::uint8_t channel, std::uint8_t note, std::int64_t absolute) noexcept
 The absolute sample position at which absolute is emitted, derived only from the spec and the event's own coordinate.
static std::uint8_t jittered_velocity (HumanizeSpec spec, std::uint8_t channel, std::uint8_t note, std::int64_t absolute, std::uint8_t velocity) noexcept
 The velocity velocity becomes, derived only from the spec and the event's own coordinate.

Static Public Attributes

static constexpr std::uint64_t kTimingStream = 1
 Random streams are separated so changing one amount cannot shift the other's draw for the same note.
static constexpr std::uint64_t kVelocityStream = 2

Detailed Description

template<std::size_t MaximumPendingAttacks = 128>
class pulp::midi::Humanize< MaximumPendingAttacks >

MaximumPendingAttacks bounds how many attacks can sit in the jitter window at once.

It is deliberately a polyphony bound rather than the whole 16x128 key space: the key space would make the kernel a 64 KiB object and would put a 2048-slot scan on the audio thread for every event, to buy headroom no keyboard can reach.

Constructor & Destructor Documentation

◆ Humanize()

template<std::size_t MaximumPendingAttacks = 128>
pulp::midi::Humanize< MaximumPendingAttacks >::Humanize ( HumanizeSpec spec = {})
inlineexplicitconstexprnoexcept

Member Function Documentation

◆ contract()

template<std::size_t MaximumPendingAttacks = 128>
constexpr MidiUtilityContract pulp::midi::Humanize< MaximumPendingAttacks >::contract ( )
inlinestaticconstexprnoexcept

◆ empty()

template<std::size_t MaximumPendingAttacks = 128>
bool pulp::midi::Humanize< MaximumPendingAttacks >::empty ( ) const
inlinenoexcept

◆ flush()

template<std::size_t MaximumPendingAttacks = 128>
MidiUtilityProcessReport pulp::midi::Humanize< MaximumPendingAttacks >::flush ( MidiBuffer & output,
timebase::SamplePosition block_start )
inlinenoexcept

Emit every attack still waiting in the jitter window.

The caller passes the block the flush belongs to so the released attacks keep sample offsets inside it.

◆ is_identity()

template<std::size_t MaximumPendingAttacks = 128>
constexpr bool pulp::midi::Humanize< MaximumPendingAttacks >::is_identity ( HumanizeSpec spec)
inlinestaticconstexprnoexcept

True when the spec cannot change any event, which is the kernel's declared bypass identity.

◆ jittered_position()

template<std::size_t MaximumPendingAttacks = 128>
std::int64_t pulp::midi::Humanize< MaximumPendingAttacks >::jittered_position ( HumanizeSpec spec,
std::uint8_t channel,
std::uint8_t note,
std::int64_t absolute )
inlinestaticnoexcept

The absolute sample position at which absolute is emitted, derived only from the spec and the event's own coordinate.

Exposed so a test or a UI can predict the schedule without pushing events through the kernel.

◆ jittered_velocity()

template<std::size_t MaximumPendingAttacks = 128>
std::uint8_t pulp::midi::Humanize< MaximumPendingAttacks >::jittered_velocity ( HumanizeSpec spec,
std::uint8_t channel,
std::uint8_t note,
std::int64_t absolute,
std::uint8_t velocity )
inlinestaticnoexcept

The velocity velocity becomes, derived only from the spec and the event's own coordinate.

Never returns 0, because 0 would silently turn an attack into a release.

◆ process()

template<std::size_t MaximumPendingAttacks = 128>
MidiUtilityProcessReport pulp::midi::Humanize< MaximumPendingAttacks >::process ( const MidiBuffer & input,
MidiBuffer & output,
timebase::SamplePosition block_start,
std::int32_t block_samples )
inlinenoexcept

◆ replace_spec()

template<std::size_t MaximumPendingAttacks = 128>
MidiUtilityProcessReport pulp::midi::Humanize< MaximumPendingAttacks >::replace_spec ( HumanizeSpec spec,
MidiBuffer & output,
timebase::SamplePosition block_start )
inlinenoexcept

◆ reset()

template<std::size_t MaximumPendingAttacks = 128>
MidiUtilityProcessReport pulp::midi::Humanize< MaximumPendingAttacks >::reset ( MidiBuffer & output,
timebase::SamplePosition block_start )
inlinenoexcept

◆ spec()

template<std::size_t MaximumPendingAttacks = 128>
HumanizeSpec pulp::midi::Humanize< MaximumPendingAttacks >::spec ( ) const
inlineconstexprnoexcept

◆ update_spec_for_future_attacks()

template<std::size_t MaximumPendingAttacks = 128>
bool pulp::midi::Humanize< MaximumPendingAttacks >::update_spec_for_future_attacks ( HumanizeSpec spec)
inlinenoexcept

Change the spec used to schedule future attacks without disturbing attacks already materialized in the pending queue.

Their final velocity and scheduled position are stored in each slot, so changing the source spec cannot reinterpret or drop them.

◆ valid()

template<std::size_t MaximumPendingAttacks = 128>
bool pulp::midi::Humanize< MaximumPendingAttacks >::valid ( ) const
inlineconstexprnoexcept

◆ valid_spec()

template<std::size_t MaximumPendingAttacks = 128>
constexpr bool pulp::midi::Humanize< MaximumPendingAttacks >::valid_spec ( HumanizeSpec spec)
inlinestaticconstexprnoexcept

Member Data Documentation

◆ kTimingStream

template<std::size_t MaximumPendingAttacks = 128>
std::uint64_t pulp::midi::Humanize< MaximumPendingAttacks >::kTimingStream = 1
staticconstexpr

Random streams are separated so changing one amount cannot shift the other's draw for the same note.

◆ kVelocityStream

template<std::size_t MaximumPendingAttacks = 128>
std::uint64_t pulp::midi::Humanize< MaximumPendingAttacks >::kVelocityStream = 2
staticconstexpr

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