Introduction: How to Send MIDI Music to the Spielatron
This Instructable covers the software tools we use to easily take standard music notation, convert it to a MIDI file and play it on the Spielatron.
Step 1: FOSS
Wherever possible we use Free & Open Source Software (FOSS) running on a Linux computer, in this case using Ubuntu Mate.
Step 2: Arranging or Composing Music to Play
As our music abilities are limited, composing is not a real option, and to avoid copyright issues we like to arrange old classics into single line pieces suitable for the Spielatron. Basically you need to keep the music monophonic ie single note only and within the Spielatron's note range G5 to G7. For this purpose we use Musescore which we have found to be totally awesome for this purpose and for creating musical scores from which to play.
We use the Linux 64 bit app image available from
One trick we use to keep the notes on the stave considering the high register of the Spielatron is to use the Treble Clef 8va option from the Clef Pallette, note the small 8 above the treble clef.
One of the great things about Musescore is the amazing community providing help, tutorials, examples and lots of Musescore files to download.
Step 3: Export a MIDI File
Once you are happy with your musical composition in Musescore you need to export it as a MIDI file. This is in File - Export and select the file format Standard Midi.
Step 4: Connecting the Spielatron to ALSA MIDI Programs
As we now wish to send our MIDI file to the Arduino on the Spielatron we need a connection between a USB device eg. ttyUSB0 and MIDI software eg. ALSA programs. Also this connection is at a computer baud rate rather than the standard MIDI baud rate of 31250.
Fortunately someone else has already written a driver program to perform this task called ttymidi.
ttymidi is available from here:
This program is only supplied as source code with a make file. When we ran the make file we received a linker error and had to modify the make file as follows.
Original command line which gave the errors
gcc src/ttymidi.c -o ttymidi -lasound
modified command line which worked
gcc src/ttymidi.c -o ttymidi -lasound -lpthread
In the end we did not run the make file and only compiled it with the command line above, so it is not installed on our system. When we wish to run ttymidi we open a terminal window, change directory to the ttymidi directory and execute the program as per the image above. With no switches used ttymidi defaults to 115200 baud rate which matches the code we supplied for the Spielatron. Note that once ttymidi is executed the terminal window does not return to the command prompt until "control c" is entered which exits the program.
Step 5: Setting a MIDI Device Name and USB Port
In this example we have used ttymidi with no switches which defaults to using ttyUSB0 and 115200 baud rate. If for any reason you needed to change these eg. you had more than one ttyUSB device connected to your computer, you can use the switches as shown in the picture above.
Step 6: Using LMMS
LMMS (formerly Linux MultiMedia Studio) is a digital audio workstation application program which is another totally awesome program that we are only beginners at using. LMMS is available from the Ubuntu Software Centre or here https://lmms.io/
Although for this purpose we are not using LMMS to play the MIDI file from the computer, LMMS still expects a sound font to be available to use when importing MIDI files. Therefore we are using Unison sound font which is available here:
To use the sound font all you need to do is extract the file into a directory that you are going to keep and then in LMMS go to Edit - Settings - Folders to set Unison as the default sound font, as per the picture above.
Step 7: Import Your MIDI File Into LMMS
Import the MIDI file you created with Musescore (or from any other source) into LMMS. Use File - Import as per the picture above.
Step 8: Set LMMS Output to TtyUSB0
Once the MIDI file is imported it will appear in the Song Editor window as a Unison track. Go to the gear wheel symbol on the left end of the track. Left click on the gear wheel, select Midi then Output and you should see a device called ttymidi (or the name that you supplied with the -n switch when starting ttymidi) as per the picture above. Select this device and you should see a tick beside it.
Step 9: Stop Computer Sound Output
If you play the track at this point, LMMS will output the MIDI file to both ttyUSB0 (the Spielatron) and the computer sound card. As the Spielatron software has a 200ms delay to allow for the rotational sevos to travel, the Spielatron's music is delayed by this amount which will be out of sync with the computer sound card output. This can be overcome by turning down the volume on the Unison track as per the picture above.
Step 10: Hit Play, Sit Back and Enjoy the Music!
Press play button as per the picture above and the Spielatron or any other Arduino music synth will play your MIDI piece. In the example at the end of the opening video the Spielatron on location plays the well known Old English folk song Greensleeves.
Apart from the music needing to be monophonic and within the range of G5 to G7, there is obviously a limitation imposed by the response time of the servos. This means that your music is limited either by the shortness if note used or the beats per minute (BPM) used. ie. if you have a high BPM then you will not be able to use very short notes or vice versa.
120 BPM at 4/4 time (4 beats per bar) gives 30 bars in 1 minute.
60 seconds divided by 30 gives 2 seconds per bar.
Therefore a crotchet will have 500ms each (easily within the servo delay time).
A quaver will have 250ms (just in the time allowing 200ms for rotation & 40ms for hammer travel).
A semiquaver is just not on without reducing the BPM.
We have a be nice policy.
Please be positive and constructive.