Giter VIP home page Giter VIP logo

Comments (2)

sandsmark avatar sandsmark commented on May 29, 2024

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++; }

from tinysoundfont.

schellingb avatar schellingb commented on May 29, 2024

I committed a "fix" for this. Not a nice solution but it seemed better than breaking the API at this point.

from tinysoundfont.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.