Arduino MIDI Filter – Revisited

This is a minor update to my Arduino MIDI Filter to allow it initialise patches as well as filter MIDI if required.

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 or Nano
  • One of the Arduino MIDI Interfaces
  • Source of MIDI data and something to send it to
  • Breadboard and jumper wires

The Circuit

This utilises the RX and TX pins using, as you might expect, RX to receive the full, unfiltered MIDI message stream, and TX to send out the filtered stream.

You can connect them both or individually to one of the Arduino MIDI Interfaces or to a DIY MIDI Interface.  In my case I had the RX coming out from a common MIDI “distribution point” for my Lo-Fi Orchestra and the TX to one of the Ready-Made MIDI Modules for driving my MT32-Pi. 

The Code

This uses the same code as before but has the following additions:

  • There is now a list of instruments at the start which contain the voice/patch numbers (1 to 128) to be used for MIDI program change messages on that channel on startup.
  • In the Arduino’s setup() routine, it works through the list of channels and if enabled and the patch number is non zero, it sends a MIDI program change message to that channel.

The rest is pretty much as described in the original Arduino MIDI Filter code.

I’m using this to sit before my MT32-Pi to filter out unwanted MIDI messages and initialise it with a specific voice for use with my Lo-Fi Orchestra.

Note that the filter as written still only passes through MIDI note on and note off messages.  There are two ways to expand on this if required:

  • More cases can be added to the main loop for messages to pass.
  • A default case could be added to pass through all messages, but then use explicit alternative cases to ignore specific types of message.

Example of adding extra messages (untested, but hopefully you get the idea):

byte cmd = MIDI.getType();
switch (cmd) {
case midi::NoteOn:
case midi::NoteOff:
case midi::ControlChange: // New Message Type
MIDI.send(MIDI.getType(), MIDI.getData1(), MIDI.getData2(), MIDI.getChannel());

Example of passing all messages except specific ones (again, untested):

byte cmd = MIDI.getType();
switch (cmd) {
case midi::ProgramChange:
case midi::ControlChange:
// Ignore these messages
MIDI.send(MIDI.getType(), MIDI.getData1(), MIDI.getData2(), MIDI.getChannel());

Find it on GitHub here.

Closing Thoughts

I’m thinking of some kind of “IO daughter board” for the MT-32Pi, and having a built-in MIDI filter might be a really useful add-on.

It would be nice to be able to set up a channel number and possible voice number somehow without having to change the code though, so some kind of simple user-interface (e.g. buttons or pots) might be a useful thing to have.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s