Arduino MIDI device

Arduino-controlled MIDI device  Arduino-controlled MIDI device The master made this electronic musical instrument for his son. He studies at a music school and in the future must be trained on such instruments as the xylophone, marimba and glockenspiel. Such tools are expensive and then it was decided to make a tool on their own.
Tools and materials: -Multiplexer 74HC4067; -Arduino; -Piezoelements;
-Wood planks;
Step one: general information
This step is optional. In it the wizard provides a number of links to familiarize yourself with the work of Arduino, piezo sensors, MIDI libraries, etc.
After all, it doesn't use any midi libraries. He programs everything needed with a line of code and a serial interface.
The big problem in the manufacture of the device was the speed of the Arduino. Will he be able to “interrogate” three and a half octaves of piezo sensors in time? The problem was solved by tweaking the analog input a little to speed it up.
The technical principle of this tool is piezo sensors, multiple analog multiplexers, and Arduino analog inputs. The sensors are configured in software. You can control the sensitivity and delay of each input.
MIDI Drum Kit: …
Electronic Drum Kit: http: // …
Drum Kit: https: // …
Arduino Xylophone: https: //
Source code: https: // …
MIDI manual: https: // …
MIDI and arduino:
https: // …
https : // // // list = PL4_gPbvyeb .. .
https: // -…
Step Two: Mechanical
The keys are made of wood. It is solid wood and can be played with a variety of sticks. piezo elements are glued to the bottom of the keys with epoxy glue. To reduce vibration between the sensors, he pasted small pieces of spongy rubber on the plates.
There are 42 keys in total, so that at the end there were three and a half octaves of tone.
 Arduino-controlled MIDI device Arduino-controlled MIDI device  Arduino-controlled MIDI device Arduino-controlled MIDI device Arduino-controlled MIDI device Arduino-controlled MIDI device Arduino-controlled MIDI device Arduino-controlled MIDI device Step three : analog multiplexer
To collect an analog signal, the device uses analog multiplexers connected to the analog inputs of the Arduino. One multiplexer can handle up to 16 channels. For 42 sensors, he used three multiplexers.
Arduino-controlled MIDI device Arduino-controlled MIDI device Arduino-controlled MIDI device Arduino-controlled MIDI device Step four: scheme
The device is assembled according to the diagram below. The instrument control buttons are set up like electronic synthesizer pedals, there is no difference.
Arduino-controlled MIDI device Arduino-controlled MIDI device Arduino-controlled MIDI device  Arduino-controlled MIDI device Arduino-controlled MIDI device Step five: code
The main program is divided into subroutines.

  //midiLoopback ();  

Can be added if some kind of midi loop is needed. Add optocoupler and midi-in connector here.

  readSensors ();  

This routine reads data from all sensors in the multiplexed arrays. The subroutines read three inputs at once and store them in an array.

  checkSensors ();  

The next subroutine is to analyze the values ​​read earlier. If the sensor has been activated, the program waits for a while before analyzing the signal again. This is to reduce fluctuations. The program sets the duration of the midi note and, depending on the octave value, sets the corresponding note read from the array of notes.

  checkPedal ();  

This section is for analyzing the pedal sustain. The procedure does not depend on the note.


The wizard uses the Ketron SD4 to generate sounds using the midi controls. He also saved some of the instruments in the user bank of the device, which he looped using the midi program change knob. Using a different sound processor, the user has to tweak these lines of code.

  checkOctave ();  

Octave button is checked and toggles MID-LOW-MID-HIGH-MID -… With this function, the maximum octave range is five and a half octaves.
Further explanations of some subroutines.
This procedure is intended to speed up the reading of analog readings.

 //Making analog readings faster (for drumrolls) works with this code //read http & # 58; // ... for more info #define FASTADC 1 //defines for setting and clearing register bits #ifndef cbi #define cbi (sfr, bit) (_SFR_BYTE (sfr) & amp; = ~ _BV (bit)) #endif #ifndef sbi #define sbi (sfr, bit) ( _SFR_BYTE (sfr) | = _BV (bit)) #endif #if FASTADC //set prescale to 16 sbi (ADCSRA, ADPS2); cbi (ADCSRA, ADPS1); cbi (ADCSRA, ADPS0); #endif  

The values ​​of the notes played on the midi, the sensitivity and release time of the piezo transducers can be determined individually for each transducer. The wizard has set the same values ​​for all sensors, but you can make more detailed settings.

 //Midi-Notenwerte unsigned char PadNote & # 91; 72 & # 93; = & # 123; 36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55, 56,57,58 , , 84.85,,100,101,102,103,104,105,106,107}; //Threshold Werte, Anschlagsempfindlichkeit //Tuning-Bedarf! Ch 10 int PadCutOff & # 91; 48 & # 93; = & # 123; 300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300, 300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300; //time each note remains on after being hit int MaxPlayTime & # 91; 48 & # 93; = & # 123; 50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50 , 50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50 }; //array of flags of pad currently playing boolean activePad & # 91; 48 & # 93; = & # 123;, , }; //counter since pad started to play int PinPlayTime & # 91; 48 & # 93; = & # 123;, , };  

The MIDI controls are in the last part of the code. The baud rate is set to 31.250 baud.

 //*********************************************** ************************************************* ***************** //Transmit MIDI Message //************************* ************************************************* *************************************** void MIDI_TX (unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY) & # 123; status = MESSAGE + midichannel; Serial.write (status); Serial.write (PITCH); Serial.write (VELOCITY); } //MIDI Program Change void MIDI_PC (unsigned char PROGRAMNUMBER) & # 123; status = 192 + midichannel; Serial.write (status); Serial.write (PROGRAMNUMBER); } //MIDI Control Change void MIDI_CC (unsigned char State) & # 123; status = 176 + midichannel; Serial.write (status); Serial.write (64); Serial.write (State); }  

All code below.
 Arduino-controlled MIDI device Everything is ready. According to the master, “This is a really fantastic instrument. You can play everything your sound processor can do with the midi controls.
My son is very happy. Now he can practice playing the marimba or xylophone almost like a real instrument. “
 MIDI device powered by Arduino


Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button