Sysex with Launchpad MK2 and usbhost_t36

Status
Not open for further replies.
Hi everyone!

I am trying to rewrite my Processing code, that makes my Launchpad MK2 work like a sequencer, to Arduino so it can run on a Teensy 3.6. I am sending and receiving MIDI now, however I get stuck on sending sysex messages to the Launchpad.

For example, in my Processing code I send three sysex messages:
Code:
myLaunchpad1.sendMessage( new byte[] {(byte)0xF0, (byte)0x00, (byte)0x20, (byte)0x29, (byte)0x02, (byte)0x18, (byte)0x0E, (byte)0x00 } ); // reset launchpad
myLaunchpad1.sendMessage( new byte[] {(byte)0xF0, (byte)0x00, (byte)0x20, (byte)0x29, (byte)0x02, (byte)0x18, (byte)0x22, (byte)0x02, (byte)0xF7} ); // session layout select (user 2)
myLaunchpad1.sendMessage( new byte[] {(byte)0xF0, (byte)0x00, (byte)0x20, (byte)0x29, (byte)0x02, (byte)0x18, (byte)0x28, (byte)0x00, (byte)0x59, (byte)0x05, (byte)0xF7 } ); // scene launch volume button RED pulse

I am trying to do the same in Arduino by running this in setup():

Code:
  #include "USBHost_t36.h"

USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
USBHub hub3(myusb);
MIDIDevice_BigBuffer midi1(myusb);

void setup() {
  Serial.begin(115200);

  while (!Serial) ; // wait for Arduino Serial Monitor
  Serial.println("USB Host Testing");
  myusb.begin();
  delay(3000);

  uint8_t resetSysEx[] =
  {
    0xF0, 0x00, 0x20, 0x29, 0x02, 0x18, 0x0E, 0x00 // reset launchpad
  };
  uint8_t sessionLayoutSysEx[] =
  {
    0xF0, 0x00, 0x20, 0x29, 0x02, 0x18, 0x22, 0x02, 0xF7 // session layout select (user 2)
  };
  uint8_t pulseButtonSysEx[] =
  {
    0xF0, 0x00, 0x20, 0x29, 0x02, 0x18, 0x28, 0x00, 0x59, 0x05, 0xF7 // pulse volume scene launch red
  };

  midi1.sendSysEx(resetSysEx, 8, true, 1);
  midi1.sendSysEx(sessionLayoutSysEx, 9, true, 1);
  midi1.sendSysEx(pulseButtonSysEx, 11, true, 1);


However I am not achieving the same results. When I look at the output I get the following four lines repeatedly (I deleted 60x "00" for each MIDI Data line):

IDIDevice transmit complete
MIDI Data: 14 61 41 00
MIDIDevice transmit complete
MIDI Data: 14 00 19 41
MIDIDevice transmit complete
MIDI Data: 14 00 00 19
MIDIDevice transmit complete
MIDI Data: 14 41 00 00
MIDIDevice transmit complete

When I was looking for some sysex issues I found a lot on buffersizes, however I do not feel that the messages I am trying to send are that large?

Can anybody tell me what I am doing wrong here?

Thanks! :)
 
I found the problem! The sysEx function should be called with the lenght of the array first, and the sysex array argument second:
Code:
midi1.sendSysEx(8, resetSysEx, true, 1);

I was confused by the "mySystemExclusiveChunk" function which shows them the other way around.

Solved :)
 
Status
Not open for further replies.
Back
Top