View Single Post
Old 01-28-2018, 11:07 AM   #303
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

How do I send and receive sysex midi messages (more than 3 bytes) within CSurf plugin?

I've found some related code inside mini SDK sources (babyhui.cpp) and Padre's Automap csurf plugin.
The thing is that Padre's plugin is tied with Automap SDK, to which I don't have access, and babyhui.cpp confuses me SYSEX_TRACKTITLE_LEN variable, which is set to 13, while the resulting sysex message would be much longer.

Here's the code from babyhui.cpp that I'm trying to adapt to my project.
It should display track's title on the surface's LCD, presumably, though I couldn't find any type of display in Mackie's Baby HUI photos.
Even if I would be able to do that successfully, there would still be a need to not only send sysex messages in my plugin, but also to receive them. I need help from someone experienced, here.

Code:
  void SetTrackTitleImpl(int trackid, const char* title)
  {
    if (m_midiout && trackid >= 0 && trackid < 256) {
      #define SYSEX_TRACKTITLE_LEN 13
      unsigned char sysex[SYSEX_TRACKTITLE_LEN] = { 0xF0, 0x00, 0x00, 0x66, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7 };
      sysex[7] = trackid;
      int i, len = (title?strlen(title):0);
      for (i = 0; i < min(len, 4) && title[i]; ++i) {
        sysex[8+i] = title[i];
      }
      
      char buf[sizeof(MIDI_event_t)+SYSEX_TRACKTITLE_LEN];
      MIDI_event_t* msg = (MIDI_event_t*) buf;
      msg->frame_offset = -1;
      msg->size = SYSEX_TRACKTITLE_LEN;
      memcpy(msg->midi_message, sysex, SYSEX_TRACKTITLE_LEN);
      m_midiout->SendMsg(msg, -1);
    }
  }
fundorin is offline   Reply With Quote