Static Public Member Functions | List of all members
universal_midi_packets::Conversion Struct Reference

Functions to assist conversion of UMP messages to/from other formats, especially older 'bytestream' formatted MidiMessages. More...

Static Public Member Functions

template<typename PacketCallbackFunction >
static void toMidi1 (const MidiMessage &m, PacketCallbackFunction &&callback)
 Converts from a MIDI 1 bytestream to MIDI 1 on Universal MIDI Packets. More...
 
static void toMidi1 (const MidiMessage &m, Packets &packets)
 Converts a MidiMessage to one or more messages in UMP format, using the MIDI 1.0 Protocol. More...
 
static uint8_t scaleTo8 (uint8_t word7Bit)
 Widens a 7-bit MIDI 1.0 value to a 8-bit MIDI 2.0 value. More...
 
static uint16_t scaleTo16 (uint8_t word7Bit)
 Widens a 7-bit MIDI 1.0 value to a 16-bit MIDI 2.0 value. More...
 
static uint16_t scaleTo16 (uint16_t word14Bit)
 Widens a 14-bit MIDI 1.0 value to a 16-bit MIDI 2.0 value. More...
 
static uint32_t scaleTo32 (uint8_t word7Bit)
 Widens a 7-bit MIDI 1.0 value to a 32-bit MIDI 2.0 value. More...
 
static uint32_t scaleTo32 (uint16_t word14Bit)
 Widens a 14-bit MIDI 1.0 value to a 32-bit MIDI 2.0 value. More...
 
static uint8_t scaleTo7 (uint8_t word8Bit)
 Narrows a 16-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value. More...
 
static uint8_t scaleTo7 (uint16_t word16Bit)
 Narrows a 16-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value. More...
 
static uint8_t scaleTo7 (uint32_t word32Bit)
 Narrows a 32-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value. More...
 
static uint16_t scaleTo14 (uint16_t word16Bit)
 Narrows a 32-bit MIDI 2.0 value to a 14-bit MIDI 1.0 value. More...
 
static uint16_t scaleTo14 (uint32_t word32Bit)
 Narrows a 32-bit MIDI 2.0 value to a 14-bit MIDI 1.0 value. More...
 
template<typename Callback >
static void midi2ToMidi1DefaultTranslation (const View &v, Callback &&callback)
 Converts UMP messages which may include MIDI 2.0 channel voice messages into equivalent MIDI 1.0 messages (still in UMP format). More...
 

Detailed Description

Functions to assist conversion of UMP messages to/from other formats, especially older 'bytestream' formatted MidiMessages.

Member Function Documentation

◆ toMidi1() [1/2]

template<typename PacketCallbackFunction >
static void universal_midi_packets::Conversion::toMidi1 ( const MidiMessage m,
PacketCallbackFunction &&  callback 
)
static

◆ toMidi1() [2/2]

static void universal_midi_packets::Conversion::toMidi1 ( const MidiMessage m,
Packets packets 
)
static

Converts a MidiMessage to one or more messages in UMP format, using the MIDI 1.0 Protocol.

packets is an out-param to allow the caller to control allocation/deallocation. Returning a new Packets object would require every call to toMidi1 to allocate. With this version, no allocations will occur, provided that packets has adequate reserved space.

References universal_midi_packets::Packets::add(), gl::m, and toMidi1().

◆ scaleTo8()

static uint8_t universal_midi_packets::Conversion::scaleTo8 ( uint8_t  word7Bit)
static

Widens a 7-bit MIDI 1.0 value to a 8-bit MIDI 2.0 value.

References gl::mask, gl::x0, and gl::x1.

◆ scaleTo16() [1/2]

static uint16_t universal_midi_packets::Conversion::scaleTo16 ( uint8_t  word7Bit)
static

Widens a 7-bit MIDI 1.0 value to a 16-bit MIDI 2.0 value.

References gl::mask, and gl::x0.

◆ scaleTo16() [2/2]

static uint16_t universal_midi_packets::Conversion::scaleTo16 ( uint16_t  word14Bit)
static

Widens a 14-bit MIDI 1.0 value to a 16-bit MIDI 2.0 value.

References gl::mask, gl::x0, and gl::x2.

◆ scaleTo32() [1/2]

static uint32_t universal_midi_packets::Conversion::scaleTo32 ( uint8_t  word7Bit)
static

Widens a 7-bit MIDI 1.0 value to a 32-bit MIDI 2.0 value.

References gl::mask, and gl::x0.

◆ scaleTo32() [2/2]

static uint32_t universal_midi_packets::Conversion::scaleTo32 ( uint16_t  word14Bit)
static

Widens a 14-bit MIDI 1.0 value to a 32-bit MIDI 2.0 value.

References gl::mask, and gl::x0.

◆ scaleTo7() [1/3]

static uint8_t universal_midi_packets::Conversion::scaleTo7 ( uint8_t  word8Bit)
static

Narrows a 16-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value.

Referenced by midi2ToMidi1DefaultTranslation().

◆ scaleTo7() [2/3]

static uint8_t universal_midi_packets::Conversion::scaleTo7 ( uint16_t  word16Bit)
static

Narrows a 16-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value.

◆ scaleTo7() [3/3]

static uint8_t universal_midi_packets::Conversion::scaleTo7 ( uint32_t  word32Bit)
static

Narrows a 32-bit MIDI 2.0 value to a 7-bit MIDI 1.0 value.

◆ scaleTo14() [1/2]

static uint16_t universal_midi_packets::Conversion::scaleTo14 ( uint16_t  word16Bit)
static

Narrows a 32-bit MIDI 2.0 value to a 14-bit MIDI 1.0 value.

Referenced by midi2ToMidi1DefaultTranslation().

◆ scaleTo14() [2/2]

static uint16_t universal_midi_packets::Conversion::scaleTo14 ( uint32_t  word32Bit)
static

Narrows a 32-bit MIDI 2.0 value to a 14-bit MIDI 1.0 value.

◆ midi2ToMidi1DefaultTranslation()

template<typename Callback >
static void universal_midi_packets::Conversion::midi2ToMidi1DefaultTranslation ( const View v,
Callback &&  callback 
)
static

Converts UMP messages which may include MIDI 2.0 channel voice messages into equivalent MIDI 1.0 messages (still in UMP format).

callback is a function that accepts a single View argument and will be called with each converted packet.

Note that not all MIDI 2.0 messages have MIDI 1.0 equivalents, so such messages will be ignored.

References universal_midi_packets::Utils::bytesToWord(), gl::data, universal_midi_packets::Utils::getChannel(), universal_midi_packets::Utils::getGroup(), universal_midi_packets::Utils::getMessageType(), universal_midi_packets::Utils::getStatus(), scaleTo14(), scaleTo7(), gl::v, gl::x0, and gl::x2.

Referenced by universal_midi_packets::ToUMP1Converter::convert().


The documentation for this struct was generated from the following file: