Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
ump_conversion.hpp File Reference

Bidirectional conversion between MIDI 1.0 (MidiBuffer) and MIDI 2.0 UMP (UmpBuffer). More...

#include <pulp/midi/buffer.hpp>
#include <pulp/midi/message.hpp>
#include <pulp/midi/ump.hpp>
#include <pulp/midi/ump_buffer.hpp>
#include <cstdint>

Go to the source code of this file.

Classes

struct  pulp::midi::Midi2ProgramChange
 Decoded fields of a MIDI 2.0 Channel Voice Program Change (status 0xC). More...

Namespaces

namespace  pulp
namespace  pulp::midi

Functions

uint16_t pulp::midi::scale_7_to_16 (uint8_t v7)
 Scale a 7-bit value (0..127) to 16-bit (0..65535) per MIDI 2.0 spec.
uint8_t pulp::midi::scale_16_to_7 (uint16_t v16)
 Scale 16-bit (0..65535) down to 7-bit (0..127).
uint32_t pulp::midi::scale_14_to_32 (uint16_t v14)
 Scale a 14-bit value (0..16383, center 8192) to 32-bit (center 0x80000000) using MIDI 2.0 Min/Center/Max scaling so the midpoint is preserved exactly.
uint16_t pulp::midi::scale_32_to_14 (uint32_t v32)
 Scale a 32-bit value back to 14-bit (0..16383), inverse of scale_14_to_32.
UmpPacket pulp::midi::midi1_event_to_ump2 (const MidiEvent &ev, uint8_t group=0)
 Convert a single MIDI 1.0 event to a MIDI 2.0 Channel Voice UMP packet.
void pulp::midi::midi1_to_ump (const MidiBuffer &src, UmpBuffer &dst, uint8_t group=0)
 Append a MIDI 1.0 buffer to a UmpBuffer as MIDI 2.0 UMP packets.
Midi2ProgramChange pulp::midi::ump_program_change_fields (const UmpPacket &p)
 Decode a MIDI 2.0 Program Change packet's fields without converting it.
bool pulp::midi::ump_to_midi1_event (const UmpPacket &p, MidiEvent &out)
 Convert a UMP Channel Voice packet into a MIDI 1.0 event when possible.
bool pulp::midi::ump_is_bank_valid_program_change (const UmpPacket &p)
 True when p is a MIDI 2.0 Program Change carrying a valid bank, i.e.
void pulp::midi::ump_to_midi1 (const UmpBuffer &src, MidiBuffer &dst)
 Flatten a UmpBuffer into a MidiBuffer.

Variables

constexpr uint8_t pulp::midi::kBankSelectMsbCc = 0
 MIDI 1.0 controller numbers carrying Bank Select for a program change.
constexpr uint8_t pulp::midi::kBankSelectLsbCc = 32

Detailed Description

Bidirectional conversion between MIDI 1.0 (MidiBuffer) and MIDI 2.0 UMP (UmpBuffer).

Scaling follows the MIDI 2.0 spec (M2-115-U §2.4, "Data Value Scaling"):

  • 7-bit → 16-bit velocity: v16 = (v7 << 9) | (v7 >> ((v7>0)?5:32)) with v7==0 staying 0 for note-off semantics.
  • 14-bit → 32-bit: center-biased expansion.

These helpers are deliberately header-only and allocation-free apart from destination-buffer append behavior. For realtime use, reserve the destination MidiBuffer/UmpBuffer and enable its realtime capacity limit so overflow is counted instead of growing storage.