There are drawbacks to doing this. For one thing proper MIDI pads or keyboards can sense velocity (how hard you hit the keys) which can be used to control volume for example. And the ideal layout for battling alien invasions isn't necessarily the one you'd want to write the next Four Sticks. But if you've got some kind of gamepad lying about that you want to transform into a miniature drum kit then it's certainly possible.
The trick is that most synths, including drumkits like Hydrogen, talk MIDI. Since it stands for "Musical Instrument Digital Interface" you can probably guess that most gamepads do not. Gamepads usually use a protocol called USB-HID "Human Interface Device". But since these are all just 0s and 1s shuffling around your computer we should be able to find something that can redirect them from one to the other. The something I used is called Pure Data.
Pure Data is a "data flow programming language", in simple terms you draw lines between things you want to connect. Once you've got a "patch" (graph) you like that's the program and you just run it.
Pure Data isn't part of normal Fedora, but you can get it easily by following the instructions at Planet CCRMA (pronounced 'karma'). Just follow the "Adding the planet CCRMA repositories." instructions, then do
yum install pd-extendedto get Pure Data, this is actually one of their examples. (CCRMA is the Stanford University Centre for Computer Research in Music and Acoustics.)
Then it's just "pd" to run it, or start it from the menu.
Getting graphicIt's possible to just load the patch and run it, but read on if you want to know what it's doing or how to adjust it.
Things aren't quite as simple as joining a 'X-Box' box to a 'Hydrogen' box, mainly because we need to say what we want the buttons to do. This is the whole patch:
"makenote" generates midi notes and "noteout" sends them into the world. The two numbers are "velocity" (100 out of 127) and duration (10ms, which Hydrogen will ignore).
Each one maps to a slot in the Hydrogen dumkit starting at 36 for the first slot (the kick drum in the normal kit). With the default kit this means:
- A - Tom low
- B - Snare Jazz
- X - Closed HH
- Y - Snare rock
- Left shoulder - Crash
- Top right - Stick
- Back - Tom Mid
- Start - Pedal HH
- Big-X - Kick
Bash it outDownload the patch.
Load PD and Hydrogen (and Jack if you're using it). Since Hydrogen uses the ALSA MIDI system set the PD output to ALSA too (the "Media" menu). If you're using QJackCtl to manage Jack you can also look at the ALSA MIDI tab to check PD and Hydrogen have connected.
Then just load the patch in PD and set it running by toggling edit mode (Ctrl-e, or menu, Edit|Edit mode). Click the top left print to check which input number you need, use the radio box to select it and then click the checkbox if it's empty.
Things not working?
- Check note numbers are coming up in the PD console when you press buttons (that's the text window that launches when you run PD). If not you might have a problem with the HID input, look carefully at the 'print' information again.
- If note numbers are coming up, check Hydrogen is working by clicking on a drum name in the main window, that should play a sample. If it doesn't then Hydrogen isn't able to play sound properly. If it does there might be a MIDI connection problem, check the MIDI-in light at the top of the Hydrogen window flashes when you press a button. If it doesn't then MIDI signals aren't being received.
Beat a drum?This certainly works and is quite fun to play with. If nothing else it was a good way to find out whether it's worth going ahead and getting some proper MIDI controllers for this.
For those on Windows or Mac, PD-extended and Hydrogen are both available for these, so you should be able to get this working there too.