Open sandsmark opened 3 years ago
Something like this fixes it, but it's ugly:
diff --git tml.h tml.h
index 31a7b9b..5bbd515 100644
--- tml.h
+++ tml.h
@@ -88,8 +88,8 @@ typedef struct tml_message
// - pitch_bend for TML_PITCH_BEND messages
union
{
- struct { union { char key, control, program, channel_pressure; }; union { char velocity, key_pressure, control_value; }; };
- struct { unsigned short pitch_bend; };
+ struct { union { char key, control, program, channel_pressure; }; union { char velocity, key_pressure, control_value; }; } param;^M
+ struct { unsigned short bend; } pitch;^M
};
// The pointer to the next message in time following this event
@@ -331,7 +331,7 @@ static int tml_parsemessage(tml_message** f, struct tml_parser* p)
{
int param;
if ((param = tml_readbyte(p)) < 0) { TML_WARN("Unexpected end of file"); return -1; }
- evt->key = (param & 0x7f);
+ evt->param.key = (param & 0x7f);^M
evt->channel = (status & 0x0f);
switch (evt->type = (status & 0xf0))
{
@@ -340,17 +340,17 @@ static int tml_parsemessage(tml_message** f, struct tml_parser* p)
case TML_KEY_PRESSURE:
case TML_CONTROL_CHANGE:
if ((param = tml_readbyte(p)) < 0) { TML_WARN("Unexpected end of file"); return -1; }
- evt->velocity = (param & 0x7f);
+ evt->param.velocity = (param & 0x7f);^M
break;
case TML_PITCH_BEND:
if ((param = tml_readbyte(p)) < 0) { TML_WARN("Unexpected end of file"); return -1; }
- evt->pitch_bend = ((param & 0x7f) << 7) | evt->key;
+ evt->pitch.bend = ((param & 0x7f) << 7) | evt->param.key;^M
break;
case TML_PROGRAM_CHANGE:
case TML_CHANNEL_PRESSURE:
- evt->velocity = 0;
+ evt->param.velocity = 0;^M
break;
default: //ignore system/manufacture messages
@@ -482,7 +482,7 @@ TMLDEF int tml_get_info(tml_message* Msg, int* out_used_channels, int* out_used_
for (;Msg; Msg = Msg->next)
{
time_length = Msg->time;
- if (Msg->type == TML_PROGRAM_CHANGE && !programs[(int)Msg->program]) { programs[(int)Msg->program] = 1; used_programs++; }
+ if (Msg->type == TML_PROGRAM_CHANGE && !programs[(int)Msg->param.program]) { programs[(int)Msg->param.program] = 1; used_programs++; }^M
if (Msg->type != TML_NOTE_ON) continue;
if (time_first_note == 0xffffffff) time_first_note = time_length;
if (!channels[Msg->channel]) { channels[Msg->channel] = 1; used_channels++; }
I committed a "fix" for this. Not a nice solution but it seemed better than breaking the API at this point.
Goddamn annoying that they haven't updated to C99 compatibility in even C++20, apparently.