SD Card Config

In version 2.1 of the robotic xylophone, MIDI files are read directly from an SD card inserted into a data logger shield.  This section explains how to load MIDI files onto the SD card, so that they can be read and processed by the Arduino program.


MIDI files can be organized into directories (folders) on the SD card.  Only directories at the root level are supported (that is, no sub-directories within a directory).  Directory names should not be more than 8 characters.  If a directory name is more than 8 characters, the Arduino program will displays it as the 8-character short filename.  For example, the directory “My Music Folder” will be shown as “MYMUSI~1”.  There can be up to 250 directories on the SD Card.  An example is shown below:

SD - Folders

Creating directories is optional.  If you don’t want to organize your MIDI files into different directories, or if you don’t have very many MIDI files, it will also work to simply put all MIDI files in the root directory.  The software allows the user to select the current directory via the configuration menu.

MIDI and INI Files

Inside each directory are MIDI files (*.MID), INI files (*.INI), and Playlist files (*.TXT).  These files define which songs are available, and what is shown on the LCD.  Again, the filenames must be in the 8.3 short filename format.  Below are some example MIDI and INI files in one of the directories.

SD - Songs 2

Each MIDI file may have a corresponding INI file, with the same base filename, but a different extension.  For example, the MIDI file ACHYBR01.MID has a corresponding INI file of ACHYBR01.INI.  The INI file is optional.

The INI file is a text file with up to 6 lines of information:

  • Line 1: Song Title (required)
  • Line 2: Additional Information 1 (optional)
  • Line 3: Additional Information 2 (optional)
  • Line 4: Song Length in Seconds (optional)
  • Line 5: Song Transpose in Half Steps (optional)
  • Line 6: Target Highest Note of Song (optional)

Below is an example of this INI file.

INI File Description

The first line is Song Title, which is what is shown in the song selection menu.

LCD - Song Select

If the INI file is not found on the SD card, then the name of the MIDI file is substituted.  An example of the song selection menu without the INI files is below:

LCD - Song List MIDI

Additional Information 1 and Additional Information 2 (Lines 2 and 3) are shown during the song play.  In this example these fields are used to show the artist and album/year of the song, although any arbitrary text could be displayed here.

Line 4 is the song length in seconds.  During song play, the LCD shows both the elapsed play time, and the total song length.

LCD - Song Playing - All Info

If the song length is not specified, only the elapsed play time is shown, as below:

LCD - Song Playing - No Total Time

If Additional Information 1 and/or 2 are not specified, the program fills in the blank lines with asterisks:

LCD - Song Playing - Only Title 2

The Line 5 (Transpose) and Line 6 (Target Highest Note) are used to define an optimal transpose for the MIDI file when played to the xylophone.  See the MIDI Transpose page for details.


Playlist Files

Playlist Files (with an extension of .TXT) are stored in the same directory as MIDI files.  These are used to define a subset of MIDI files in the directory to show in the song selection list.  For example, there could be a Playlist of Christmas songs to use during the holiday season, and maybe you’d want a Playlist of 1980’s songs that you would use for people that you know like this period.  And then there could be another playlist called “All” that shows all songs in the directory.

An example of a playlist file on the SD card is shown below.

SD - TXT File in Directory

The Playlist file simply contains a list of the MIDI files (the 8.3 short filename) that are to be shown on the list of the LCD.  Songs are displayed on the LCD in the same order that they are defined in the Playlist file.  The selected playlist is changed via the Configuration menu.

SD - TXT File

It may seem that allowing both for different directories and for different playlists is redundant.  The advantage of using playlists is that it is possible to show the same MIDI file in different lists, without having to copy the file into different directories.  Also, playlists allow for displaying the list of songs alphabetically.  Without the playlist file, songs are displayed in the order returned by the SD card file system, which may or may not be in alphabetical order.

The advantage of allowing different directories is that it will allow you to store many more songs on the same SD card.  Each directory can contain up to 250 different MIDI files.  Since there can also be up to 250 directories, a total of 62,500 MIDI files can be copied onto one SD card, and all will be accessible at runtime through the menu.  Another advantage of using different directories is that you can keep different versions of the same song.  For example, you might use one directory to keep a short version (30-60 seconds) of each song, which is useful for demos.   Another directory could have the corresponding full-length songs.

When you are satisfied with the MIDI, INI, and Playlist files that you have copied, remove the SD card from your computer, insert it into the Data Logger Shield, and power-up the robotic xylophone.

Next: Operation