JQ6500 MIDI MP3 Player Module

As I mentioned last time, I want to turn m JQ6500 into a MIDI-driven sample player.  This project describes how to do that.

  • In part 2, I turn this into a simple shield.

Warning! I strongly recommend using an old or second hand keyboard for your MIDI experiments.  I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

  • Arduino Uno
  • JQ6500 MP3 Player Module (or “JQ6500 Voice Sound Module)
  • 8 ohm speaker or old headphone speaker
  • 1x 1kΩ resistor
  • MIDI In circuit (see Arduino MIDI Interfaces)
  • Breadboard and jumper wires

The Circuit

JQ6500 MIDI MP3 Player Module_bb

This is essentially the same circuit as before but with the addition of one of the Arduino MIDI Interfaces for a MIDI In link.

The Code

This is using the JQ6500 Serial library as previously described along with the Arduino MIDI Library.  The code is using MIDI call-back functions to handle NoteOn events on the required channel.

The basic idea is that a number of MP3 files are uploaded to the JQ6500 using the USB link and the “uploader” application (as previously described) and the code defines a list of MIDI note numbers that will correspond to each file.  It is up to you to get the right number of files to notes as there is no real checking going on.

The ordering of the files is a little weird – the code doesn’t know anything about their naming – it only works on the order they appear in the JQ6500 memory and this order is determined by the order in which the uploader tool sends them over.   I believe that this is the order in which you select the files in the tool, but I haven’t experimented enough to check.

To get the right order of notes to files, once the files were on the JQ6500 I used the JQ6500 Serial library’s “full demo” to play each file by “index”.  The index starts at 1 and increases for each file as it works its way through the memory so running a sequence of “f 1”, “f 2”, “f 3”, and so on will play each file.  Alternatively just upload the MIDI sketch regardless and just see which file plays for each MIDI note by simply pressing keys!

Once the correct sequence is worked out, the MIDI note numbers can be stored in the “midiNotes” list near the top of the file in the right order.

The issue with playing MP3 files through MIDI like this is the lag – the module seems to have to finish playing one file before it will start the next.  You can see that at the end of the video.

There is talk in the data sheet and tutorials of using a resistor on the “play mode” pin to determine if a keypress can interrupt an already playing file, but I can’t see any way to duplicate this functionality via the serial protocol.  The default resistor setting is “no resistor” which should correspond to letting the playback be interruptable, so I haven’t quite worked this bit out yet.

To keep things even vaguely useful I edited my MP3 files (which I found on the Internet) to make them all as short as I thought I could get away with and with minimal lead time for each sound.  But whilst this means it isn’t much fun to play as a MIDI instrument, I’m really only thinking of using it as a MIDI driven sound effects unit, so that shouldn’t really be an issue.

Find it on GitHub here.

Closing Thoughts

I believe I’m only using around 64KB of the 2MB of available memory, so there is plenty of room for more sounds – so if I had more samples (or recorded my own) I should be able to play much more than one octave of white notes.

The latency is an issue using this as an MP3 piano though, so that is probably a bit of a dead end really.  This really works best for higher quality samples, infrequently triggered – so sound effects or unusual percussion instruments – which is actually what I’d like to use it for.

Kevin

Leave a comment