A position sensitive midi drum pad

Step 9Software setup

Software setup
Once you have built the pad and the electronics to work with it, the next thing is to attach it to a computer and start making some music!

I have attached all the necessary software to do this under linux in a .tgz archive. If you have trouble downloading this, the latest version is always available here.

If you want to use windows or mac, it shouldn't be too hard to convert the programs if you have some programming experience. (The only system specific bit is the part of the midimapper program which deals with serial input from the arduino and midi output to the internal midi bus. This program is in python.)

Please bear with me and take the time to work through these instructions. The software is in an early development state at the moment, so not as easy to use as it could be.

There are three main bits of software:

The arduino firmware reads the analogue signals produced by the 4 piezos and turns them into raw readings for each strike.

The midimapper receives the strike data from the arduino and converts it into x-y coordinates then feeds these to a software midi port as note on and controller messages (using controllers 70 and 71). The x coordinate is also duplicated in the midi note number of the note on message. The program is in a pretty crude state at the moment - it is a command line program in python which you control using short commands:

The midi messages are read by the supercollider software (which is basically one program but currently in 2 separate files) and turned into sounds which depend on the position and velocity of the strike.

At the moment, you need to start all these programs separately.

First, load the arduino sketch piezodrum2 onto the arduino. You can find instructions on how to do this on the arduino site. You can test it is working by hitting the pad - it should print a string of numbers on the usb serial device every time you hit the pad.

If you have rebooted the computer since you loaded the firmware, you will need to run the script resetty to put the serial port into the right mode to run the midimapper.

You also need to install the pyseq python library for the midimapper to work. There may be a package for your distro, or else see here.

Then edit the midimapper file (mmap.py) if necessary to set the right usb serial port device. Now start this program from the command line. The commands are as follows:
  • midi - start sending midi events.
  • stop - stop sending midi events, or stop calibration.
  • calib - go into calibration mode.
  • save - save calibration coefficients.
  • load - load calibration coefficients.
  • saveraw - save raw calibration data.
  • calfile - recalibrate from saved raw data.
  • quit - leave the program.
You have to calibrate the pad at least once before you can use the midi mode. When you start the calibration, the program will ask you to strike the pad several times (5 is good) in a series of points on the grid you have marked out. The names of these points are mostly self explanatory except for 'top left mid', which is half way between the top left corner and the centre of the pad. Same for 'top right mid' etc.

Once you have calibrated the pad, use 'save' to save the calibration data for next time you run it, then 'midi' to go into midi mode. (You only need 'saveraw' if you are thinking of modifying the formula used to map the raw readings into coordinates). At this point you can check the midimapper is working by watching its output in the terminal - every time you strike the pad it should print out the x and y coords of the strike.

Next you can start up the supercollider programs. See the supercollider site for instructions on installing and using this programming language. The easiest way I have found to use it in linux is to use the plugin for gedit. You will probably also need the jack sound system for outputting sounds.

The program 'drummidi.sc' just reads the incoming midi signals and sends them to a synth called 'MidiDrum'. 'synpad.sc' has various suitable synth definitions ('synthdefs') to work with this. First choose a synthdef you like the sound of from the description and evaluate it (i.e. select it in the editor and press ctrl-E). Then evaluate all the code in 'drummidi.sc' - this will start the program running.

The final step is to connect the midi out port from the midimapper to the midi in port for supercollider, using a program like qjackctl or aconnectgui.

Once you have done this, your pad should start making sounds. Celebrate, try making some music, do a rain dance, whatever works for you!
« Previous StepDownload PDFView All StepsNext Step »
2 comments
Mar 12, 2010. 7:40 PMzen.webb says:
 Have you considered using the Arduino itself to extrapolate the sensor data and output MIDI notes directly, perhaps through a true MIDI cable? 

I see the Python code has some potentially CPU intensive math so it may introduce an unacceptable amount of lag if ported to the Arduino, but maybe not, especially if you upgrade to a more powerful Arduino or clone. 

In practice do you find that the calibration functions you have written help much? Or did you introduce that because you noticed noise in the system? I would like to see if this device can be optimized into a more plug-and-play package. This sucker has some fantastic potential.
Mar 12, 2010. 8:49 PMzen.webb says:
 Also, what is the equation you use to integrate the the piezo signals into an XY position? I'm just going to copy the code, but was just curious if its a well-known equation, maybe there is a reasonably analogous alternative function out there for CPU calculations.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
9
Followers
3
Author:ganglion(Highfellow)
I live in the North West of England, and work part time as a computer programmer / electronics technician.