A Position Sensitive Midi Drum Pad

56K16651

Intro: A Position Sensitive Midi Drum Pad



The SynPad is a position sensitive midi drum pad that you can build yourself using simple materials and tools for around 50 UK pounds (depending on what materials you already have, and how many pads you want to make.) The pad can detect where you have hit it as well as how hard, so that the synth it is driving can change the sound continuously as you strike the pad in different places.

The software I have written to make the sounds is currently linux based, but would not require much work to adapt to a windows or mac environment.

The skills you need are basic wood and metal work (cutting and drilling), enough electronics knowledge to build a simple circuit from the schematic, and a moderate amount of experience with making music on the linux operating system. You don't need any programming experience to start making sounds under linux, but would if you want to create your own synths to make different sounds, or to port the program to another OS.

If you have built one of these pads, or are thinking of building one, it would be good to hear from you.

Hope you enjoy making and playing this instructable!



STEP 1: Design

The project is still in early prototype stage. The current design uses a 30 cm square aluminium sheet as the active surface, with piezo sensors mounted under each corner to pick up the pressure pulse caused when you hit the pad with a stick or your fingers. The pad is supported on closed cell foam rubber discs, inside a plywood frame. When you hit the pad, the sensors in each corner respond differently according to where you have hit it.

The signals from each sensor are captured by an arduino micro-controller board, which then sends the raw signal strength from each sensor to a computer over its usb cable. When the sensor data reaches the computer, it is interpreted by a python program which calculates the coordinates and velocity of the strike from the raw figures, and then maps this information onto midi note and controller values.

What happens next is up to you - if you want, you can feed the midi data into any Linux softsynth just as you would for any other midi source like a keyboard. To make the most of the position sensitivity of the pad, though, you want a synth that will change the sound produced according to the x and y position of the strike. The simplest way of doing this is to use one of the music programming languages like supercollider, csound, or pure data. Some example supercollider synths are in the archive attached to the final step of this instructable.

Unfortunately I forgot to take proper photos of each step as I was building the pad - the ones that I have attached are really assembly photos that show the main parts before you bolt them together. They should give you enough of an idea though to build one yourself.

STEP 2: Tools and Materials

You will need the following materials:

  • a 30 cm square sheet of 3mm thick aluminium.
  • a 30 cm square of thick plywood (e.g. 10mm) for the base.
  • a 30 cm square sheet of thin plywood (e.g. 5 mm) for the top frame.
  • a small amount of 10mm closed cell foam rubber (enough to make 8 * 35mm discs). I bought some online, but you could probably use the rubber from something like a camping mat or old style mouse pad. Soft (open cell) foam of the sort you get in cushions probably wouldn't work.
  • 8 * 5mm machine screws, around 55 mm long (and matching nuts and washers). If you can, get the kind where the nuts have a plastic insert to stop the nut from loosening.
  • 4 * 35mm diameter piezo transducers.
  • 4 small metal discs a bit smaller than the inner contact of the piezo. (E.g. 4 one pence coins).
  • Some 30 Awg wire (i.e. v. thin) to wire the piezos.
  • Some shielded 1 core cable to carry the signal from the piezos to the arduino.
  • Contact adhesive which will stick rubber, wood and metal.
  • Epoxy adhesive.
  • Gaffer tape.
  • 4 * 1 MOhm resistors.
  • 2 * 10 KOhm resistors.
  • 1 * 100 Ohm resistor.
  • 1 * TS912 Op-amp.
  • 1 * 2N3904 npn transistor.
  • A breadboard or piece of stripboard to build the circuit on.
  • Solder.
  • Miscellaneous jumper wires.
  • An arduino board and usb cable. Any of the arduino boards will do - you just need 4 analogue inputs.
  • Magic marker for marking the aluminium sheet.
and the following tools:
  • Saw to cut the plywood sheets to size.
  • Pad saw / fret saw with metal and wood cutting blades. This is for cutting the central hole in the top frame. You only need the metal cutting blade if you need to cut the aluminium sheet to size.
  • Electric drill.
  • 5 mm wood drill bit.
  • 10 mm metal drill bit.
  • Large wood drill bit for making the initial hole to use the pad saw through.
  • Screwdriver.
  • Soldering iron.
  • Wire strippers.

STEP 3: Cutting the Plywood and Aluminium Sheets

The first thing is to mark out the plywood and aluminium sheets and cut them to size. The whole pad is 30cm square from edge to edge, and all the sheets need cutting to this size first. You will need a pad saw with a blade for cutting metal if you can't buy aluminium cut to size.

Next you need to cut a square hole in the top plywood sheet (the thinner sheet) to make a frame. I was using 35mm piezos (any smaller probably wouldn't work as the rubber would squash too much), and a gap of 5mm around these, making the width of the border of the top frame 45 mm. So the next step is to cut the top sheet into a frame with 45mm width left around each edge. To do this, mark out a line 45mm in from each edge, then drill large holes inside the corners of this square. Then use the padsaw with a wood cutting blade to cut out the central part.

You may want to sand the edges of the plywood sheets at this point to make it look neater.

STEP 4: Drilling the Bolt Holes

Now you need to drill holes for the bolts that will hold the pad together. The important point is that the holes in the metal sheet are 10 mm whereas the ones in the wooden frame are 5mm, so the metal sheet is held in place just by the pressure of the rubber mounts, and is free to move up and down.

Each hole is in line with the centres of the piezos, 10 mm from the piezo's edge. This translates to 22.5 mm x 50mm from each corner. There are 2 bolt holes at each corner.

It is easiest if you start with making the holes in the aluminium (which are 10mm), and then use this as a template for the top frame and the base. This way, any mistakes in drilling the aluminium won't matter so much as the holes will still line up. The top frame and base need 5mm bolt holes to match the machine screws. Mark each sheet with an arrow on one edge before drilling to show the alignment, so you will be able to line them up the same way each time.

STEP 5: Soldering the Piezos

The next thing is to solder up the piezos. You want to use quite thin wire for the actual connection, then solder this to the thicker shielded cable that takes the signal to the arduino. The smaller disc on top of the piezo is ground, and the larger one underneath is the positive. Ideally, solder the shield of the cable to the piezo's earth and the inner core to the positive.

If you get to the end of the project and find that you have the polarities wrong, don't panic! The current firmware on the arduino only deals with absolute values not positive and negative, so it shouldn't make too much difference.

Once this is done, use epoxy to glue a small metal disc (e.g. a 1 pence coin) to the top of each piezo to provide a bit of clearance above the wires and make a solid contact with the bottom of the aluminium sheet. Make sure the disc, and the glue you use, are only on the top, inner disc of the piezo's ground electrode, not touching the outer disc.

STEP 6: Making and Gluing the Rubber Mounts

Now you can cut the 8 rubber mounts. They can be cut fairly roughly from the sheet to the same diameter as the piezos. These should be glued in the corners of the base board and top frame using contact adhesive, 5mm from the edge. Make a thin film of glue on both surfaces and let it go to touch dry before putting them together.

Then glue the piezos on top of the ones on the base board (again using contact adhesive). Mark the cables so you know which sensor they come from. Top left is 1, top right is 2, bottom left is 3, and bottom right is 4. Tape the cables from the sensors to the base board with gaffer tape, so that they come out on one side.

STEP 7: Assembling the Pad

The final step is to assemble the pad. Put the machine screws in from the bottom, then rest the aluminium sheet on the base board so the machine screws come through the centre of the holes with plenty of space around them. Then put the top frame on.

At this point you need to decide how you are going to mark out the playing surface of the pad for calibration later. The pad is calibrated by striking it in different places while running the calibration program. These places are defined in the program as 13 specific points placed on a 5x5 grid (5 lines not 5 spaces). I started by using 1.5cm clearance from the inner edge of the top frame, but if you want to play with sticks (I am now using timpani sticks), you may want to make the clearance a bit bigger.

When you have decided how much clearance you'll need when playing, take the top sheet off again and mark it up with magic marker. You need a 5x5 grid with enough clearance round the edges for you to strike the pad at each corner. It's also handy to label the corners 1,2,3, and 4 the same as the sensor cables.

Now put the sheet back on, put the washers and nuts on the bolts, and tighten the nuts to finger pressure. Check again that there is good clearance around each of the bolts where it goes through the aluminium sheet. You may want to cut the machine screws down to the exact size with a hacksaw at this point. Be sure to do this with the nuts on, or you'll find it hard to put them on afterwards. It would also be wise to blunt any sharp edges afterwards with a small file.

Finally, tighten each of the bolts by the same amount - 3 whole turns works for me. The pad itself is now finished!

STEP 8: Building the Circuit

The pad uses a very simple electronic circuit to feed the sensor signals from the pad into the arduino. All this really does is make a false ground at half the 5v power supply produced by the arduino. The circuit diagram is attached below - I don't want to describe every step you need to take to build this on breadboard or stripboard, but it's not too hard.

STEP 9: 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!

STEP 10: Final Thoughts

I've enjoyed making the pad and playing about with different sound effects.

Timpani mallets, which are felt headed bamboo sticks, work nicely with the pad if you don't want to use your fingers.

The midimapper program is a bit crude at the moment, and I'm hoping to develop this further to make it easier to use and add some more features.

The position sensing is reasonably good - about 5% accuracy which is enough to make some interesting variations as you play a rhythm.

I would also like to make a few more pads and work out a way to connect more than one to the computer at the same time.

For playing, I have been putting the pad on a flat square piece of soft packing foam to reduce the amount of interference from external vibrations. This might get incorporated into later designs. It would also be nice to tidy up the general look and feel of the pad, by painting it and putting the electronics in a proper box.

I would like to thank Alaric Best for his ideas on the design, which set me off on the track the current pad is based on.

If you make one of these yourself, it would be nice to know how it went - you can get in touch by sending me a private message.

For more information, and any software updates, see:

highfellow.org/synpad

Good luck!

53 Comments

Hello
I have built this successfully but still facing a problem that my all the piezo are producing only one sound.... So please tell me how to assign individual sounds to each piezo while I am using FL Studio as my working software... Please anyone who know how to fix it, help me...out
How did you get on with working through page 9 - 'software setup' in my instructions?

If you have the midi mapper installed and configured, then it should be sending notes to your midi device with the X and Y coordinates of the strike sent using midi controllers 71 and 72, and the strike velocity in the midi note velocity. You'll then need to find a way to map these midi parameters into changes in the sound in the software you're using. I don't know how FL Studio is laid out so can't really advise on this. Alternatively you can set up the supercollider program I included in the software package as a way of generating sounds.

I'm not sure how this is going to work in a windows environment though, as the midi mapper script was written to run in linux.

I've uploaded the most recent release of my software as an attachment to page 9 of the instructable, which should help. Sorry for not remembering to do this earlier.
I just converted my acoustic set into an electronic set. I am currently using the Alesis I/O you can find it on Ebay or Amazon for about $ 150 dlls. new even cheaper used.

I will post a much more detailed tutorial of the whole process from making your own mesh heads to making your custom sensor mounts and the very little electronics involved in each double zone drum. Yes I know that you are building your module from scratch but this may help others less electronics savvy.

Great job by the way.
Sounds like a neat project - have fun!

how much would you charge to make me one?

I'm not up for making them for other people at the moment. For a start the design would need a lot of work before I felt comfortable asking someone to pay money for what is really an experimental setup. I'd suggest you also look at this project: http://madronalabs.com/DIY, which is better than what I came up with in that it is more playable and can detect multiple simultaneous strikes.

I was wondering if you could generally explain how your circuit works? Am I correct in thinking that your circuitry on the left is basically a fancy diode / one-way valve? It looks to me like it is supplying a constant 5V power to all piezo sensors when none of them are in use, and uses the op-amp to supply voltage directly from the piezo sensors themselves if they are hit with enough force to overcome the 5V battery.

But I was just wondering, why not just use a diode?
The reason for using that circuit is because I wanted to be able to track negative going as well as positive going pulses from the piezo. When you hit it, it starts going positive, then oscillates both negative and positive. If the negative terminal of the piezo was just connected to the ground of the arduino, the negative part of the pulse would be below ground, and wouldn't be picked up by the ADCs.

What this circuit does is to halve the input voltage using a voltage divider, then use an opamp / transistor buffer to provide a constant voltage at that level (roughly 2.5 volts). Then when the voltage from the piezo goes negative, it's relative to that 2.5 volt false ground, not to the ground of the arduino.

The program on the arduino does a short calibration when it starts up to work out what the resting voltage from each piezo is. That value is then subtracted from each reading.

There might be better / simpler ways of doing this, but that's the way I did it in my first version, which I'm still using, and it seems to work ok.
cool, thanks!

I've taken another look at the circuit and brought up the datasheet for the TS912 and noticed a problem. In your schematic you have your ~2.5V output of the voltage divider section going into pin 1 of the TS912. According to the datasheet below, pin 1 is for output....are the pin numbers just incorrect in your schematic, or did you use a slightly different chip?

http://www.st.com/stonline/products/literature/ds/2325/ts912.pdf
Sorry about that. You are right that the pin numberings are wrong on my circuit. I'll put up a corrected version in a minute.

The 2.5v divider should be feeding into the non-inverting input of the op-amp (pin 3), the feedback from the resistor should be on the inverting input (pin 2), and the output to the piezos should be on pin 1. It wouldn't hurt as well to put a high value electrolytic capacitor (100 uf?) across the 100 ohm resistor to make sure that the current into the piezos isn't drawing the ~2.5V rail up or down in voltage.
Thanks for the fantastic instructable. I'm trying to adapt your circuit to make a detector for a BB gun shooting range, so we know when we hit the targets. The way I have the circuit set up now is too simple, just the piezos and the 1M resistor, and its very susceptible to electronic interference. So I'm building out your circuit now to try to make it a bit more reliable.

I had one question: I wasn't able to find the TS912 op-amp locally, but instead found the TL082. The package is labelled "Dual BiFET Op Amp", and here's some specs:

http://www.national.com/mpf/TL/TL082.html

Do you think that would work as a replacement?

Interesting use for this circuit! :-)

Bear in mind that just using this circuit won't make your system more reliable - the reason for creating a 2.5v reference level like this is so that the firmware can detect both positive and negative going pulses from the piezos. Apart from that it will work pretty much like the simple input circuit you are using. Are you using shielded cable for the connection between the piezos and the arduino? This would help with reducing interference.

That opamp might work, but I'm not sure. It looks from the datasheet like it's designed for a higher voltage application, with split power supplies. The useful thing about the TS912 is it is 'rail to rail', which means that its input and output voltage ranges go right from the positive to the negative supply voltages. Also it's designed for low voltage applications (2.7 V minimum).

This isn't a very demanding use for an opamp, but it does need to be able to provide an output voltage of about 3.1V to drive the transistor. I'm not sure from the datasheet whether the TL082 will do that off a 5v single rail supply.

If you search for a general purpose rail to rail op-amp, you should find something that does the trick.
P.S. I can't get the circuit designer I'm using (GNU EDA) to remove the wrong pin numberings from the op amp, so I've just put up a new version with no numbers. The '+' and '-' signs on the inputs should be enough for people to read the schematic, I think.
Thanks, things make a little more sense now! :P

Did you also happen to change the resistor values across each piezo from 10M to 1M? Or am I remembering it wrong?
They were always 1M as far as I remember.
Hi ganglion
this looks deceptively simple, but as engaging as Randy Jones' physical drum model:
http://vimeo.com/2433260

before I try to emulate your hardware system, am I right in assuming you are using the Z-axis (force/velocity) from the piezo's as well as X/Y location? I wonder if four FSRs (under foam, then perspex) in each corner would work just as well?
Yes, the velocity value is worked out from the sum of values in each corner. For the position, I use a least squares curve technique to fit an equation to a set of calibration data.

Not sure about FSRs (force sensitive resistors?). They might be worth trying, and could work perfectly well because really it's just sensing the transferred pressure at each corner, but I don't know much about their properties.

I guess the thing would be to go ahead and try it - it would be good to have someone experimenting with a different physical construction, so let me know how you get on.

andy
This seems like it could work in a circular form, to simulate a multi-zone snare or cymbal. How accurate are the coordinate calculations? I'm a n00b to Arduino and my only experience with programming is a few C++ classes, but based on the code I've read, this might be something I could try. I'm still waiting for my first board to arrive next week, though.
You may have good luck constructing a square pad but overlaying a round frame on top of it. Then you can modify the code to ignore all piezo signals or coordinates that are from strikes in the corners of the device that you don't want to be active.
More Comments