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

Immutable MIDI clip content: start-then-identity-ordered notes with sparse deterministic modifiers, beside the controller and expression streams those notes sound against. More...

#include <clip.hpp>

Public Member Functions

runtime::Result< MidiContent, ModelError > replace_note (NoteEvent note) const
 Returns a new snapshot replacing the note with the same identity.
std::span< const NoteEvent > notes () const noexcept
 Returns notes in canonical (start, id) order.
std::span< const NoteModifier > modifiers () const noexcept
 Sorted by note id and containing only notes whose playback differs from the default, so a document that authors no modifiers carries none.
std::uint64_t modifier_seed () const noexcept
 Returns the authored seed used to derive per-note probability draws.
std::span< const MidiExpressionLane > lanes () const noexcept
 Controller and expression streams in (address, id) order, each lane's points in (position, id) order.
const MidiExpressionLane * lane_for (const MidiLaneAddress &address) const noexcept
 The lane addressing address, or nullptr when the clip authors none.
const NoteModifier * modifier_for (ItemId note_id) const noexcept
 The modifier for note_id, or nullptr when the note plays by default.

Static Public Member Functions

static runtime::Result< MidiContent, ModelError > create (std::vector< NoteEvent > notes)
 Notes alone: no modifiers, no lanes, and a zero seed.
static runtime::Result< MidiContent, ModelError > create (std::vector< NoteEvent > notes, std::vector< NoteModifier > modifiers, std::uint64_t modifier_seed)
 Notes plus their sparse modifier companion array.
static runtime::Result< MidiContent, ModelError > create (std::vector< NoteEvent > notes, std::vector< NoteModifier > modifiers, std::uint64_t modifier_seed, std::vector< MidiExpressionLane > lanes)
 Notes, modifiers, seed, and the clip's controller/expression lanes.

Detailed Description

Immutable MIDI clip content: start-then-identity-ordered notes with sparse deterministic modifiers, beside the controller and expression streams those notes sound against.

Notes and lanes are separate storage because they answer different questions. A note is asked "which notes start inside this block", which wants events ordered by time across the whole clip. A controller stream is asked "what was your value at this instant", which wants each stream's own history, independently searchable, so that seeking never costs a walk over unrelated streams.

Member Function Documentation

◆ create() [1/3]

runtime::Result< MidiContent, ModelError > pulp::timeline::MidiContent::create ( std::vector< NoteEvent > notes)
static

Notes alone: no modifiers, no lanes, and a zero seed.

Every note plays once, unconditionally.

◆ create() [2/3]

runtime::Result< MidiContent, ModelError > pulp::timeline::MidiContent::create ( std::vector< NoteEvent > notes,
std::vector< NoteModifier > modifiers,
std::uint64_t modifier_seed )
static

Notes plus their sparse modifier companion array.

Each modifier must name a note in notes, must be well-formed, and must not be neutral — a neutral entry is a second encoding of a note that already plays that way. modifier_seed is the document's authored seed for probability draws; the same seed always reproduces the same decisions.

◆ create() [3/3]

runtime::Result< MidiContent, ModelError > pulp::timeline::MidiContent::create ( std::vector< NoteEvent > notes,
std::vector< NoteModifier > modifiers,
std::uint64_t modifier_seed,
std::vector< MidiExpressionLane > lanes )
static

Notes, modifiers, seed, and the clip's controller/expression lanes.

Every lane and point identity must be valid and distinct from every other identity this content owns, including the note identities, and no two lanes may share an address. Lanes are returned in (address, id) order and their points in (position, id) order regardless of the order supplied.

◆ lane_for()

const MidiExpressionLane * pulp::timeline::MidiContent::lane_for ( const MidiLaneAddress & address) const
noexcept

The lane addressing address, or nullptr when the clip authors none.

◆ lanes()

std::span< const MidiExpressionLane > pulp::timeline::MidiContent::lanes ( ) const
inlinenoexcept

Controller and expression streams in (address, id) order, each lane's points in (position, id) order.

Both orderings are what makes a seek cheap: the stream is found by binary search over this span, and its value at an instant by binary search within that lane's points. A clip that authors no controllers carries no lanes.

◆ modifier_for()

const NoteModifier * pulp::timeline::MidiContent::modifier_for ( ItemId note_id) const
noexcept

The modifier for note_id, or nullptr when the note plays by default.

◆ modifier_seed()

std::uint64_t pulp::timeline::MidiContent::modifier_seed ( ) const
inlinenoexcept

Returns the authored seed used to derive per-note probability draws.

◆ modifiers()

std::span< const NoteModifier > pulp::timeline::MidiContent::modifiers ( ) const
inlinenoexcept

Sorted by note id and containing only notes whose playback differs from the default, so a document that authors no modifiers carries none.

◆ notes()

std::span< const NoteEvent > pulp::timeline::MidiContent::notes ( ) const
inlinenoexcept

Returns notes in canonical (start, id) order.

The span remains valid while this MidiContent snapshot remains alive.

◆ replace_note()

runtime::Result< MidiContent, ModelError > pulp::timeline::MidiContent::replace_note ( NoteEvent note) const

Returns a new snapshot replacing the note with the same identity.

Modifiers, seed, and every lane carry over untouched: replacing a note changes what that note plays, never what the clip's controllers say. Fails if the identity is absent or the replacement note is invalid.


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