Mission accomplished! The finished drum booth. >>

DIY Arduino MIDI instrument

2019-08-30 10:40:36
And another summer project got finished... ;-)
My sons drum corps teacher triggered me to build an Arduino Midi controller so he could practice his rhythm skills.

Inspiration

The easiest library is the Arduino Midi USB library as described here. Although I was not very happy with the code provided...

A project on Instructables showed how the piezos could be used and also some ports of the code were used.

My version


I protected the red wire on the piezos with a piece of tape and taped each one of those on an aluminum plate. After testing on a breadboard, I used a stack-on board to easily add the resistors.



This is the scheme used:



Sources

The Arduino code inspired by the examples can be found on my GitHub account.

The two separate functions but with very similar code "noteOn" and "noteOff" were rewritten to one "sendNote" function. Also "MidiUSB.flush();" was moved into this function because at some point I forgot to add it and this caused strange behavior when playing music as the notes were not "released":
void sendNote(boolean on, byte note, byte velocity) {
  // First parameter is the event type (0x09 = note on, 0x08 = note off).
  // Second parameter is note-on/note-off, combined with the channel.
  // Channel can be anything between 0-15. Typically reported to the user as 1-16.
  // Third parameter is the note number (48 = middle C).
  // Fourth parameter is the velocity (64 = normal, 127 = fastest).
  byte event = on ? 0x09 : 0x08;
  byte onOff = on ? 0x90 : 0x80;
  byte onOffChannel = onOff | MIDI_CHANNEL;
  
  midiEventPacket_t noteOn = {event, onOffChannel, note, velocity};
  MidiUSB.sendMIDI(noteOn);
  MidiUSB.flush();
}


The result

Combined with EarMaster this works "out of the box" as a controller on Apple. When hitting too hard, the neighboring piezos also detect a change, so maybe I will still need to add some kind of tempering when we want to use it further, but for EarMaster this doesn't seem to be an issue.