Midi to USB for Zoom Ms70Cdr

Hi,

I am trying to control a Zoom Ms 70 CDR from a Midi foot controller via a usb Host Shield.

i have seen it done before using the following Sketch, but at the moment its not working for me i have tried different ide,s but still the same it compiles fine, but wont change programs via midi.
is there something i am missing? the midi in circuit is working fine.
so it would lead me to believe ether the sketch is faulty or the shield is faulty or i have it configured wrong.
The footswitch changes the programs fine on the zoom via midi ox, also i noticed that when i press a switch on the foot controller that the Rx led doesn’t blink.

can anyone help please

/*
 *******************************************************************************
 * Legacy Serial MIDI and USB Host bidirectional converter
 * Copyright (C) 2013-2016 Yuuichi Akagawa
 *
 * for use with Arduino MIDI library
 * https://github.com/FortySevenEffects/arduino_midi_library/
 *
 * Note:
 * - If you want use with Leonardo, you must choose Arduino MIDI library v4.0 or higher.
 * - This is sample program. Do not expect perfect behavior.
 *******************************************************************************
 */

#include <MIDI.h>
#include <usbh_midi.h>
#include <usbhub.h>

// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif

//Arduino MIDI library v4.2 compatibility
#ifdef MIDI_CREATE_DEFAULT_INSTANCE
MIDI_CREATE_DEFAULT_INSTANCE();
#endif
#ifdef USBCON
#define _MIDI_SERIAL_PORT Serial1
#else
#define _MIDI_SERIAL_PORT Serial
#endif

//////////////////////////
// MIDI Pin assign
// 2 : GND
// 4 : +5V(Vcc) with 220ohm
// 5 : TX
//////////////////////////

USB Usb;
USBH_MIDI Midi(&Usb);

void MIDI_poll();
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime);

//If you want handle System Exclusive message, enable this #define otherwise comment out it.
#define USBH_MIDI_SYSEX_ENABLE

#ifdef USBH_MIDI_SYSEX_ENABLE
MidiSysEx sysExData;
//SysEx:
void handle_sysex( byte* sysexmsg, unsigned sizeofsysex) {
  Midi.SendSysEx(sysexmsg, sizeofsysex);
}
#endif

void setup()
{
  MIDI.begin(MIDI_CHANNEL_OMNI);
#ifdef USBH_MIDI_SYSEX_ENABLE
  MIDI.setHandleSystemExclusive(handle_sysex);
#endif
  if (Usb.Init() == -1) {
    while (1); //halt
  }//if (Usb.Init() == -1...
  delay( 200 );
}

void loop()
{
  unsigned long t1;
  uint8_t msg[4];

  Usb.Task();
  t1 = micros();
  if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
  {
    MIDI_poll();
    if (MIDI.read()) {
      msg[0] = MIDI.getType();
      switch (msg[0]) {
        case midi::ActiveSensing :
          break;
        case midi::SystemExclusive :
          //SysEx is handled by event.
          break;
        default :
          msg[1] = MIDI.getData1();
          msg[2] = MIDI.getData2();
          Midi.SendData(msg, 0);
          break;
      }
    }
  }
  //delay(1ms)
  doDelay(t1, micros(), 1000);
}

// Poll USB MIDI Controler and send to serial MIDI
void MIDI_poll()
{
  uint8_t size;
#ifdef USBH_MIDI_SYSEX_ENABLE
  uint8_t recvBuf[MIDI_EVENT_PACKET_SIZE];
  uint8_t rcode = 0;     //return code
  uint16_t  rcvd;
  uint8_t   readPtr = 0;

  rcode = Midi.RecvData( &rcvd, recvBuf);

  //data check
  if (rcode != 0) return;
  if ( recvBuf[0] == 0 && recvBuf[1] == 0 && recvBuf[2] == 0 && recvBuf[3] == 0 ) {
    return ;
  }

  uint8_t *p = recvBuf;
  while (readPtr < MIDI_EVENT_PACKET_SIZE)  {
    if (*p == 0 && *(p + 1) == 0) break; //data end
    MidiSysEx::Status rc = sysExData.set(p);
    switch (rc) {
      case MidiSysEx::nonsysex :  //No SysEx message send data to Serial MIDI
        p++;
        size = Midi.lookupMsgSize(*p);
        _MIDI_SERIAL_PORT.write(p, size);
        p += 3;
        break;
      case MidiSysEx::done :      //SysEx end. send data to Serial MIDI
        _MIDI_SERIAL_PORT.write(sysExData.get(), sysExData.getSize());
        /* FALLTHROUGH */
      case MidiSysEx::overflow :  //SysEx buffer over. ignore and flush buffer.
        sysExData.clear();
        /* FALLTHROUGH */
      default:
        p += 4;
        break;
    }
    readPtr += 4;
  }
#else
  uint8_t outBuf[ 3 ];
  do {
    if ( (size = Midi.RecvData(outBuf)) > 0 ) {
      //MIDI Output
      _MIDI_SERIAL_PORT.write(outBuf, size);
    }
  } while (size > 0);
#endif
}

// Delay time (max 16383 us)
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
{
  unsigned long t3;

  if ( t1 > t2 ) {
    t3 = (0xFFFFFFFF - t1 + t2);
  } else {
    t3 = t2 - t1;
  }

  if ( t3 < delayTime ) {
    delayMicroseconds(delayTime - t3);
  }
}

Latest

Ran a test on the shield and it completed the test fine? so maybe its a incompatibility with the sketch and the shield.

The Usb host shield is a Keys by funduino.

I’ve got the same host shield and have used this code so it does work.
You say you have tried different IDE’s I found it would work best if I used the later nightly build rather than the one I installed. Just download and run it from the zip.

Give that a go and report back.

Cheers for that.

I tried as you said with the nightly build, what rev worked for you ?

Still not working, are you getting the rx led blinking when it receives midi in.

i do think its an Ide problem more than hardware.

I'm using 1.6.6.

On closer inspection of the code you posted, is that the bidirectional converter from the example? If so then no that doesn't seem to work for anyone, you might be better asking the library author directly.

The way I have got everything configured is a USB MIDI keyboard is connected to the host shield and this is converted to real MIDI out. I also have a real MIDI in circuit. Both get sent to the real MIDI out.

I think what you want to do is a real MIDI input to USB MIDI output?
This code wont do that as it stands. :frowning:

My setup is in bits at the moment so can't check if I get a flashing LED.

I found this site useful: Arduino USB MIDI converter there is also a link to a PDF which was useful too.
Someone on that page said they have the got this code to work though.

I think it will need a bit of coding but should be possible.

Thanks for that...

i see one person got it working it must be down to the revision of the usbh_midi and the ide.

i am thinking of getting one of these the owner says it will do the same job.

http://www.hobbytronics.co.uk/usb-host/usb-host-board-v2

I would suggest before getting anything else that you forget about the midi in part for now and try to send some commands vis the USB.
This will show if the library is working and board is working.

We know the MIDI in part will work.