MD_Midifile Library not sending MIDI

Hello as the topic suggests I can´t send MIDI from SD card using MD_Midifile Library. I´ve tried the MD_Midifile_Play example with own MIDIFiles and via SerialMonitor it says PLAYING. But when I change it to USE_MIDI the LED blinks in the tempo of the file, but no MIDI output.

With MD_MIDIFile_Dump I can also read the file´s content, so the problem seems to be on the output side.

Any tips?

I use an Arduino Uno, the seeeduino SD Card module 4.3 (PIN 4) and the Sparkfun MIDI Shield.

What is is sending MIDI to?

Is your serial interface correctly wired/configured?

Are your MIDI cables working?

Have you actually confirmed that the MIDI messages are not arriving at the other end of the serial connection?

Thanks for your quick reply.

It should send MIDI to the Sparkfun MIDI Shield, that sends MIDIOut via a MIDI-USB interface to my Mac laptop, that I´m monitoring via MIDI Monitor.

I did test the exact same setup by just sending MIDI Out from the standart <MIDI.h> library (so without SD card) and can receive it without problem.

When using the MD_MIDIFile library however my MIDI-USB interface does not show any activity and the MIDI monitor stays silent.

Is it possible that the SD card shield (Seeeduino v4.3) and the Sparkfun MIDI shield are not compatible?

I have unplugged everything for the nth time and now the behaviour changed: there is a steady stream of data to the MIDI-USB interface, however MIDI-monitor shows the data as invalid 1bit.

PS: I´ve noticed that when I upload the MD_MIDIFile_Play example, I get the following warning:

Sketch uses 11630 bytes (36%) of program storage space. Maximum is 32256 bytes.
Global variables use 1750 bytes (85%) of dynamic memory, leaving 298 bytes for local variables. Maximum is 2048 bytes. Low memory available, stability problems may occur.

Is it not possible to run this on an Uno?

When using the MD_MIDIFile library however my MIDI-USB interface does not show any activity and the MIDI monitor stays silent.

Is the sketch configured to send out the serial midi port or print debug? If it is printing "Playing" to the serial monitor then it cannot be sending MIDI message out that same serial port.

You can run it on an Uno. I do it all the time.

Thanks - I did re-download and re-install the SDFat and MD_MIDIFile libraries again and now it´s working like a charm.

I had a look in all examples, and can now play different midifiles once a pin is set to high. Very nice.

But I fail to do the following:

  • play a file to the end, once done
  • jump to next file (until here it works) and then
  • loop that second file

I can see there is a looping() function in the library, but don´t understand how that works.

Also:
is there a similar function to MIDIgetData1() or MIDIgetData2() in the MIDI Library? I´d like to read out the MIDI data, and use ie a MIDI cc to control a value, that controls the PWM on a pin. I can see there is something like (pev->data[0]) in the midiCallback function but don´t know how to modify that for this purpose.

I can see there is a looping() function in the library, but don´t understand how that works.

From the library documentation:

Set the looping mode for SMF playback

A SMF can be set to automatically loop to the start once it has completed. For SMF file type 0 (1 track only) the single track is looped. For file type 1, all tracks except track 0 (the first) is looped. Track 0 contains global setup information that does not need to be repeated and would delay the restart of the looped tracks.

Which bit is not clear?

You can find the documentation in the docs folder of the library. Open index.html.

The midi_event structure contains the specification for the current midi event that needs to be 'done' by the application. If you want to see examples of how it is used look at the examples in the libraries MD_SN76489 and MD_YM2413. In any event you need to understand the MIDI event codes to work with this structure. There are lots of internet references for that.