upgrade to libremidi 5.1, raylib and raygui latest

This commit is contained in:
Sebastian @ HfG
2025-06-13 19:06:09 +02:00
parent bd642576bb
commit 96bd5f30e6
112 changed files with 6484 additions and 1946 deletions
@@ -1,11 +1,13 @@
#pragma once
#include <libremidi/cmidi2.hpp>
#include <libremidi/detail/conversion.hpp>
#include <libremidi/detail/midi_in.hpp>
#include <libremidi/cmidi2.hpp>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <cinttypes>
#include <span>
namespace libremidi
@@ -107,12 +109,12 @@ struct input_state_machine : input_state_machine_base<input_configuration>
{
message.bytes.clear();
message.timestamp = {};
state = main;
m_state = main;
}
bool has_finished_sysex(std::span<const uint8_t> bytes) const noexcept
{
return (((bytes.front() == 0xF0) || (state == in_sysex)) && (bytes.back() == 0xF7));
return (((bytes.front() == 0xF0) || (m_state == in_sysex)) && (bytes.back() == 0xF7));
}
// Function to process a byte stream which may contain multiple successive
@@ -139,22 +141,22 @@ private:
void on_bytes_multi_segmented(
const message_callback& cb, std::span<const uint8_t> bytes, int64_t timestamp)
{
int64_t nBytes = bytes.size();
int64_t iByte = 0;
int64_t n_bytes = bytes.size();
int64_t i_byte = 0;
const bool finished_sysex = has_finished_sysex(bytes);
switch (state)
switch (m_state)
{
case in_sysex: {
return on_continue_sysex(cb, bytes, finished_sysex);
}
case main: {
while (iByte < nBytes)
while (i_byte < n_bytes)
{
int64_t size = 1;
// We are expecting that the next byte in the packet is a status
// byte.
const auto status = bytes[iByte];
const auto status = bytes[i_byte];
if (!(status & 0x80))
break;
@@ -170,17 +172,17 @@ private:
if (configuration.ignore_sysex)
{
size = 0;
iByte = nBytes;
i_byte = n_bytes;
}
else
{
size = nBytes - iByte;
size = n_bytes - i_byte;
}
if (bytes[nBytes - 1] != 0xF7)
if (bytes[n_bytes - 1] != 0xF7)
{
// We know per CoreMIDI API there can't be anything else in this packet
state = in_sysex;
m_state = in_sysex;
message.assign(bytes.begin(), bytes.begin() + size);
message.timestamp = timestamp;
return;
@@ -192,7 +194,7 @@ private:
if (configuration.ignore_timing)
{
size = 0;
iByte += 2;
i_byte += 2;
}
else
{
@@ -209,7 +211,7 @@ private:
if (configuration.ignore_timing)
{
size = 0;
iByte += 1;
i_byte += 1;
}
else
{
@@ -222,7 +224,7 @@ private:
if (configuration.ignore_sensing)
{
size = 0;
iByte += 1;
i_byte += 1;
}
else
{
@@ -238,14 +240,14 @@ private:
// Now process the actual bytes of the message
if (size > 0)
{
auto begin = bytes.begin() + iByte;
auto begin = bytes.begin() + i_byte;
message.assign(begin, begin + size);
message.timestamp = timestamp;
cb(std::move(message));
message.clear();
iByte += size;
i_byte += size;
}
}
}
@@ -256,7 +258,7 @@ private:
const message_callback& cb, std::span<const uint8_t> bytes, bool finished_sysex)
{
if (finished_sysex)
state = main;
m_state = main;
if (configuration.ignore_sysex)
{
@@ -283,7 +285,7 @@ private:
// SYSEX start
case 0xF0: {
if (!finished_sysex)
state = in_sysex;
m_state = in_sysex;
if (!this->configuration.ignore_sysex)
{
@@ -328,7 +330,7 @@ private:
return;
const bool finished_sysex = has_finished_sysex(bytes);
switch (state)
switch (m_state)
{
case in_sysex:
return on_continue_sysex(cb, bytes, finished_sysex);
@@ -346,7 +348,7 @@ private:
{
main,
in_sysex
} state{main};
} m_state{main};
};
}
@@ -453,6 +455,18 @@ private:
return;
break;
}
case CMIDI2_MESSAGE_TYPE_MIDI_1_CHANNEL: {
if (this->configuration.midi1_channel_events_to_midi2)
{
libremidi::ump msg;
cmidi2_ump_upgrade_midi1_channel_voice_to_midi2(bytes.data(), msg.data);
msg.timestamp = timestamp;
cb(std::move(msg));
return;
}
break;
}
}
libremidi::ump msg;