YuuichiAkagawa / Arduino-UHS2MIDI

USB Host Shield 2.0 MIDI transport layer for the FortySevenEffects Arduino MIDI Library
MIT License
23 stars 2 forks source link

SysExReceive output reverse #10

Closed OscarDory closed 2 years ago

OscarDory commented 2 years ago

When I try to read SysEx Messenger from Roland, instead of starting messenger F0 and ending F7, but it reverse Is it right ?

YuuichiAkagawa commented 2 years ago

I don't have a roland device so I can't try it. The following sample exchanges device inquired messages.

#include <UHS2-MIDI.h>

byte sysex_ir[] = { 0xF0, 0x7E, 0x7F, 0x06, 0x01, 0xF7 };

USB Usb;
UHS2MIDI_CREATE_DEFAULT_INSTANCE(&Usb);

unsigned long t0 = millis();

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void setup()
{
  Serial.begin(115200);
  while (!Serial);

  // Listen for MIDI messages on channel 1
  MIDI.begin(1);

  MIDI.setHandleSystemExclusive(OnMidiSysEx);

  if (Usb.Init() == -1) {
    while (1); //halt
  }//if (Usb.Init() == -1...
  delay( 200 );
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void loop()
{
  Usb.Task();
  // Listen to incoming notes
  MIDI.read();

  // send a note every second
  if ((millis() - t0) > 1000)
  {
    t0 = millis();
    //   Serial.print(F(".");

    MIDI.sendSysEx(sizeof(sysex_ir), sysex_ir, true);
  }
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void OnMidiSysEx(byte* data, unsigned length) {
  Serial.print(F("SYSEX: ("));
  Serial.print(length);
  Serial.print(F(" bytes) "));
  for (uint16_t i = 0; i < length; i++)
  {
    Serial.print(data[i], HEX);
    Serial.print(" ");
  }
  Serial.println();
}

No problem to see the results.

My Setting:

Please provide more information.

OscarDory commented 2 years ago

Could you explain this byte sysex_ir[] = { 0xF0, 0x7E, 0x00, 0x06, 0x01, 0xF7 }; When I turn on device Roland and serial show : F0 41 10 0 0 0 31 12 E 0 0 1 71 F7 I also test your code above, it's correct position F7 F0, the SysEx messenger when I pressed button show F7 B0 0 1 B0 20 0 C0 0 F0

YuuichiAkagawa commented 2 years ago

First, there is one correction. The third message should be 0x7F.

byte sysex_ir[] = { 0xF0, 0x7E, 0x7F, 0x06, 0x01, 0xF7 };

This is an identity request in a Universal System Exclusive Message. https://www.midi.org/specifications-old/item/table-4-universal-system-exclusive-messages

YuuichiAkagawa commented 2 years ago

Roland V-1SDI

I found the reference manual on Roland's website. Isn't it a control change or program change that sends a message when you press a button? Are you sure a SysEx will be sent?

YuuichiAkagawa commented 2 years ago

F0/F7 is not needed in CC or PC.
There is three MIDI messages.

A1:
B0 0 0 
B0 20 0 
C0 0
YuuichiAkagawa commented 2 years ago

You should learn about MIDI first. I do not support the MIDI standard and specific device.