MD_MIDIFile Standard MIDI File Processing 2.6
Library to play Standard MIDI Files (SMF)
Arduino Standard MIDI File (SMF) Player

This library allows Standard MIDI Files (SMF) to be read from an SD card and played through a MIDI interface. SMF can be opened and processed, with MIDI and SYSEX events passed to the calling program through callback functions. This allows the calling application to manage sending to a MIDI synthesizer through serial interface or other output device, such as a MIDI shield. SMF playing may be controlled through the library using methods to start, pause and restart playback. SMF may be automatically looped to play continuously. Time ticks are normally generated by the library during playback, but this can be taken over by the user program if different time or synchronization with external MIDI clock is required.

If you like and use this library please consider making a small donation using PayPal

External Dependencies

The MD_MIDIFile library uses the following additional libraries and may need additional hardware components

  • SdFat library at https://github.com/greiman?tab=repositories. Used by the library to manage the SD card file system.
  • MIDI interface hardware described in this documentation. The interface can be stand alone or built onto an Arduino shield, as required.

Topics

Revision History

Apr 2022 version 2.6.0

  • Changes file referencing from SdFat only to FAT16/FAT32/exFAT using SD_FAT_TYPE define.
  • Adjusted examples for SDFat library version 2 changes/deprecated methods.

Mar 2022 version 2.5.3

  • Corrected errors from new DEBUG statements.

Mar 2022 version 2.5.2

  • Added PlayIO example for custom I/O player.
  • Added additional explanation for callbacks for message handling.

Nov 2020 version 2.5.1

  • Adjusted setFileFolder() due to changes methods in SdFat version 2+.

Apr 2020 version 2.5

  • Added isPaused() and isLooping() methods.
  • Removed internal buffer for file name. Now can be full path and not 8.3.
  • Deprecated setFilename(), use load() with file name specified.
  • Rechecked and updated examples.

Mar 2020 version 2.4

  • Changed error codes to defined constants.
  • Changed CLI example to use MD_cmdProcessor.
  • Fixed resynch error after pause().

Sep 2019 version 2.3.2

  • Fixed buffer overflow in SetFilename().
  • Added setFileFolder() method.

Aug 2019 version 2.3.1

  • Eliminated small compiler warnings.
  • Increase MAX_TRACKS from 16 to 24.
  • Added Player_CLI example code.

Jul 2019 - version 2.3.0

  • Changed handling of SYSEX and META events with data bigger than buffer (R Foschini).
  • Fixed tick calculation by eliminating the time signature in calc (R Foschini).

Jun 2018 - version 2.2.0

  • Added handling of meta events through callback (R. Foschini contribution).

May 2018 - version 2.1.1

  • Changed SHOW_UNUSED_META to 0 as it should have been all along. Causing music to stop.

Jan 2017 - version 2.1

  • Bug fix - SdFat changed behavior, needed change TIME SIGNATURE handling case.

Aug 2014 - version 2.0

  • Renamed MD_MIDIFile Library for consistency with other MajicDesigns libraries.
  • Documentation extensively revised and now in dOxygen format.
  • Revised debug output macros.
  • Fixed some minor errors in code.
  • Added looping() method.
  • Changed timebase to be 'tick' based & corrected algorithm.
  • Allow user code to control ticks directly for sync with external MIDI clock.

Jan 2013 - version 1.2

  • Cleaned up examples and added additional comments.
  • Removed dependency on the MIDI library.
  • This version has no major changes to the core library.

Jan 2013 - version 1.1

  • Minor fixes and changes.
  • More robust handling of file errors on MIDIFile.load().

Jan 2013 - version 1.0

  • Initial release as MIDIFile Library.

Copyright

Copyright (C) 2013-20 Marco Colli All rights reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA