# Drum Pad to Midi.. Recomendation?

**URL:** <https://lookmumnocomputer.discourse.group/t/drum-pad-to-midi-recomendation/2767>\
**Category:** DIY STUFF\
**Created:** [January 24, 2021, 11:27am UTC](https://lookmumnocomputer.discourse.group/t/drum-pad-to-midi-recomendation/2767 "2021-01-24T11:27:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![twinturbo](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@twinturbo](https://lookmumnocomputer.discourse.group/u/twinturbo)\
**Post date:** [January 24, 2021, 11:27am UTC](https://lookmumnocomputer.discourse.group/t/drum-pad-to-midi-recomendation/2767/1 "2021-01-24T11:27:36Z")

</div>

Has anyone built a successful Pad To Midi Trigger?

My son want’s to ditch the cheap electronic drum module he has and just fit a Pad-2-Midi 19" Patch to feed into Ableton Live.

Seen all sorts of projects floating arround, just wondered if anyone knew the best one to try 😉

Cheers

Rob

---

<div class="post-metadata">

**Author:** ![willow2x](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/willow2x/32/5343_2.png) [@willow2x](https://lookmumnocomputer.discourse.group/u/willow2x)\
**Post date:** [January 24, 2021, 3:33pm UTC](https://lookmumnocomputer.discourse.group/t/drum-pad-to-midi-recomendation/2767/2 "2021-01-24T15:33:26Z")

</div>

Ive made a 4 pad drum/midi trigger out of an old rockband/GH drum set i had spare using a teensy 4 for the midi over usb.  
Im going to work on kick/hat pedals and cymbals when ive got the Modular built. (i started the drum kit… then got distracted by this modular gear. got me hooked by the patch cables)

Ive no idea how best to share the (botched up) code.  
ill edit up the post in a sec =)

One sketchy prototype and schem.

 ![IMG_20210124_155414](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/2X/e/e3c9cd3eec13e478eab3e8db36b51283e194003e.jpeg)

I couldnt upload the .ino. Hope this is what you were after =)  
I also hope its the right version of the code. I went through a few premade/example code and made it fit my needs until something worked =)

Janky Code - For 4 pads. (Its my first attempt at coding anything)

> /\* Use a Piezo sensor (percussion / drum) to send USB MIDI note on  
> messages, where the “velocity” represents how hard the Piezo was  
> tapped.
> 
> Connect a Pieze sensor to analog pin A0. This example was tested  
> with Murata 7BB-27-4L0. Almost any piezo sensor (not a buzzer with  
> built-in oscillator electronics) may be used. However, Piezo  
> sensors are easily damaged by excessive heat if soldering. It  
> is highly recommended to buy a Piezo with wires already attached!
> 
> Use a 100K resistor between A0 to GND, to give the sensor a “load”.  
> The value of this resistor determines how “sensitive” the circuit is.
> 
> A pair of 1N4148 diodes are recommended to protect the analog pin.  
> The first diode connects to A0 with its stripe (cathode) and the other  
> side to GND. The other diode connects its non-stripe (anode) side to  
> A0, and its stripe (cathode) side to 3.3V.
> 
> Sensitivity may also be tuned with the map() function. Uncomment  
> the Serial.print lines to see the actual analog measurements in the  
> Arduino Serial Monitor.
> 
> You must select MIDI from the “Tools \> USB Type” menu
> 
> This example code is in the public domain.  
> _multi-pad extension by oddson (under-tested)_  
> \*/
> 
> const int channel = 10; // General MIDI: channel 10 = percussion sounds  
> const int PINS = 4; // number of signals incoming
> 
> const int note[PINS] = {36,37,38,39}; // array of MIDI note values for read signals
> 
> const int analogPin[PINS] = {A0,A1,A2,A3}; //array of analog PINs  
> const int thresholdMin = 60; // minimum reading, avoid noise and false starts  
> const int peakTrackMillis = 12;  
> const int aftershockMillis = 25; // aftershocks & vibration reject
> 
> int state[PINS]; // 0=idle, 1=looking for peak, 2=ignore aftershocks  
> int peak[PINS]; // remember the highest reading  
> int piezo[PINS];  
> elapsedMillis msec[PINS]; // timers to end states 1 and 2
> 
> void setup() {  
> Serial.begin(115200);  
> while (!Serial && millis() \< 2500) /\* wait for serial monitor \*/ ;  
> Serial.println(“Piezo Peak Capture”);  
> }
> 
> void loop() {  
> for (int i=0;i\<PINS;i++){  
> //delay(20);  
> piezo[i] = analogRead(analogPin[i]);
> 
> peakDetect(i);  
> // Add other tasks to loop, but avoid using delay() or waiting.  
> // You need loop() to keep running rapidly to detect Piezo peaks!
> 
> }  
> // MIDI Controllers should discard incoming MIDI messages.  
> // [Teensy 3 + Ableton, Analog CC causes midi crash. | Teensy Forum](http://forum.pjrc.com/threads/24179-Teensy-3-Ableton-Analog-CC-causes-midi-crash)  
> while (usbMIDI.read()) {  
> // ignore incoming messages  
> }  
> }
> 
> void peakDetect(int i) {
> 
> ```
> //Serial.println(state[i]);
> 
> ```
> 
> switch (state[i]) {  
> // IDLE state: wait for any reading is above threshold. Do not set  
> // the threshold too low. You don’t want to be too sensitive to slight  
> // vibration.  
> case 0:  
> if (piezo[i] \> thresholdMin) {  
> [//Serial.print](https://Serial.print)("begin peak track ");  
> [//Serial.println](https://Serial.println)(piezo[i]);  
> peak[i] = piezo[i];  
> msec[i] = 0;  
> state[i] = 1;  
> }  
> return;
> 
> ```
> // Peak Tracking state: capture largest reading
> case 1:
> if (piezo[i] > peak[i]) {
> peak[i] = piezo[i];     
> }
> if (msec[i] >= peakTrackMillis) {
> //Serial.print("peak = ");
> //Serial.println(peak);
> int velocity = map(peak[i], thresholdMin, 1023, 1, 127);
> usbMIDI.sendNoteOn(note[i], velocity, channel);
> msec[i] = 0;
> state[i] = 2;
> }
> return;
> 
> // Ignore Aftershock state: wait for things to be quiet again.
> default:
> if (piezo[i] > thresholdMin) {
> msec[i] = 0; // keep resetting timer if above threshold
> } else if (msec[i] > aftershockMillis) {
> usbMIDI.sendNoteOff(note[i], 0, channel);
> state[i] = 0; // go back to idle when
> }
> 
> ```
> 
> }  
> }

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [January 24, 2021, 4:03pm UTC](https://lookmumnocomputer.discourse.group/t/drum-pad-to-midi-recomendation/2767/3 "2021-01-24T16:03:04Z")

</div>

I have a curb rescue Rock Band Wii drum set I’ve done nothing with other than to observe that indeed if I plug the USB into my Linux box it appears as a USB device and responds to hits.

[https://www.linuxjournal.com/magazine/hack-and-wii-will-rock-linux](https://www.linuxjournal.com/magazine/hack-and-wii-will-rock-linux)

I hope to get around to turning it into a MIDI controller eventually but that’s way down the list. I’ll watch from here though.

---

<div class="post-metadata">

**Author:** ![twinturbo](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@twinturbo](https://lookmumnocomputer.discourse.group/u/twinturbo)\
**Post date:** [January 24, 2021, 4:08pm UTC](https://lookmumnocomputer.discourse.group/t/drum-pad-to-midi-recomendation/2767/4 "2021-01-24T16:08:03Z")

</div>

Cheers,

How did it perform?

He’s got a “Session Pro” with 3 Cymbals (+Hat Pedal), Kick and two toms and a snare. So I have to account for 8 inputs.

Is there a reason you use the Teensy? And specifically the 4?

Cheers

Rob

---

<div class="post-metadata">

**Author:** ![willow2x](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/willow2x/32/5343_2.png) [@willow2x](https://lookmumnocomputer.discourse.group/u/willow2x)\
**Post date:** [January 24, 2021, 4:44pm UTC](https://lookmumnocomputer.discourse.group/t/drum-pad-to-midi-recomendation/2767/5 "2021-01-24T16:44:46Z")

</div>

> [@twinturbo](#):
>
> How did it perform?

I tested it with Sunvox for RasPi (A strange modular DAW thing) I couldnt see/feel anything wrong with it in terms of latency.  
My only complaint with GH drums is theyre so LOUD to hit. The rockband ones are much nicer and rubbery, tho still loud, they feel alot nicer to hit.

> [@twinturbo](#):
>
> Is there a reason you use the Teensy? And specifically the 4?

My bro got 2 for Xmas, he didnt need 2 and knows im into tinkering so he gave me one to play with. after that i got a few Nano’s. but i dont believe they do MIDI over USB.  
I do feel a Teensy4 is overpowered for this. but its what i had to work with and learn on at the time.  
Thankfully it does Midi over USB so there was no extra buying of cables/converters/etc. just plugged it into the Pi and its all nice n tidy =)

If you wanted to use a Nano (without midi over usb) you would need to build a little extra circuitry for a midi cable.  
[Notes’n’Volts explains it best.](https://www.youtube.com/watch?v=ellhUszaMZs)

> [@twinturbo](#):
>
> So I have to account for 8 inputs.

the teensy has 10 analog pins (A0-A9) so you should have enough to work with, you just need to amend the code a bit.  
i have no idea how pedals will work yet, that will be ‘fun’ lol

---

<div class="post-metadata">

**Author:** ![twinturbo](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@twinturbo](https://lookmumnocomputer.discourse.group/u/twinturbo)\
**Post date:** [January 24, 2021, 5:08pm UTC](https://lookmumnocomputer.discourse.group/t/drum-pad-to-midi-recomendation/2767/6 "2021-01-24T17:08:57Z")

</div>

Cheers, would probably using a MegaPro so either Serial Or USB Midi Should be OK.
