kfp
Posts: 4
Joined: Sat Feb 09, 2013 6:56 pm

Connecting RockBand Drums to GPIO

Sat Feb 09, 2013 7:48 pm

Howdy. I've just picked up my first Raspberry Pi and am quite excited. I'm a web developer who hasn't really dabbled in hardware since taking fried answering machines apart as a kid, so please excuse my ignorance when talking about this project.

I'm looking to use the RP as a drum module. Large scale is going to include modifying a real drum set, but for small scale hardware and software testing I've taken apart a Rock Band drum set. As I understand the Rock Band set uses piezo sensors. I've taken the symbols apart which are just the sensors hooked up to a mono 3.5 female jack. There is also a mono 3.5 male jack to a connector with two female connectors that fit right onto the GPIO connectors on the RP. I'd like to do a simple demo in python of simply reading and printing the input in from the cymbal while I hit it. I don't know if it will be able to tell the velocity at which the cymbal is hit, but this test should provide some answers.

I've taken a look at the picture here http://elinux.org/File:GPIOs.png but am pretty out of my league when it comes to figuring out where to which GPIO pins to connect this thing to. Does it need power? Grounding? What is CE1?

I plan on using http://code.google.com/p/raspberry-gpio-python/ to read the input for this first test, but then probably c or c++ to cut back on any latency.

Thanks for the help!

killerbobjr
Posts: 5
Joined: Thu Feb 07, 2013 6:44 am

Re: Connecting RockBand Drums to GPIO

Sun Feb 10, 2013 10:27 am

The GPIO pins are for digital data only. Commercial drum trigger modules use an A/D converter to convert the trigger output into digital data that the processor can manipulate. If you think, "That sounds simple enough," read on.

Low cost drum trigger modules multiplex several inputs into a single A/D converter, carefully designing for accurate timing across the multiplexed inputs when switching each input through to the A/D converter. Higher cost modules will use individual A/D converters for each input, making timing issues for A/D conversion moot, but driving up the overall cost of the system.

Once you have decided which method of conversion you want to use, then you have to decide if you want to have analog or digital trimming of the inputs (so your drum trigger signal doesn't go past the maximum the A/D can convert). Cheaper drum modules opt for manual trimmers (potentiometers controlling the input opamp gain) coupled with low resolution A/D converters (8 or 10 bit). Mid-cost modules might use automatic gain control (the processor controls the gain of the input opamps). Almost all drum trigger modules these days use high resolution A/D converters (16 or 20 bit) and use digital trimming (adjusting the gain after it's been converted to digital). The latter method consumes a lot more bandwidth because of the higher resolution.

When you get that sorted out, the next thing you need to consider is noise reduction. The triggers carry a whole lot of extra signal besides the main thwack, so you must filter that out. The simplest solution is an analog low pass filter on each input with adequate slope, but not so much as to cause ringing (18dB or 24dB/octave is good), and the cut off frequency not too low as to cause phase shift, affecting latency (100-200Hz cut off works well). The expensive modules do all this in software with a DSP or a very fast cpu. The Pi is not well suited for this kind of processing (for more than a few triggers), so an analog filter is your best bet.

Then you have to decide if you're going to use the Pi as an all-in-one (process the trigger signals, data manipulation, and sample output), or just as a data processor (processes trigger signals, data manipulation to convert into MIDI, then output MIDI). If an all-in-one, you will not have very much horsepower left over for handling input triggers after sending out audio. Keep in mind that even though the Pi certainly has more than enough capability to process triggers, it has much less capability to do so within 7ms or less (the approximate threshold most drummers start to detect latency). Divide that by the minimum amount of triggers you need for a simple 5 piece drum set (kick, snare, snare rim, hi tom, mid tom, floor tom, hi-hat, hi-hat pedal, crash, ride, ride bell) and all of a sudden the Pi's 700Mhz is now 700/7/11=9Mhz.

"9Mhz," you think. "Pshaw! I can do plenty in that." Well, you have to divide that by the sample accumulation rate for a trigger (use 1ms or less sampling rate to get really accurate peak detection within 2-3ms latency), plus divide by the size of the sample block you're going to be sending (the sampling rate chopped up by a rather loose 5ms latency for example) means that now you're right at the minimum of detectable latency (7ms). Because we don't want your drummer to feel like he's playing out of sync, the amount of processing time you have to detect a drum strike and send out a drum sample is now reduced to 1ms, for a total of 8ms processing time, which puts you just slightly over the average detectable latency threshold.

If all this seems confusing, start out very simply. Ignore the GPIO pins. Those are for manipulating digital signals, not audio. Instead, buy a cheap USB audio adapter. Read through the threads here on how to get that to work on the Pi. Once you can record and playback simultaneously with any available audio application, learn how to do something simple like program an application that you switch left and right channels with. Once you know how to manipulate the audio data like that, you can start experimenting with reading your drum triggers that you have plugged into the USB adapter inputs, and then sending out a drum sample at the output. Of course you're limited to 2 triggers, one each for left and right input, but it's enough to get your feet wet.

karlkiste
Posts: 189
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: Connecting RockBand Drums to GPIO

Sun Feb 10, 2013 11:29 am

killerbobjr has put up a great essay for you, just pick from there what suits your demands.

My aproach would be different, however: I'd have a go with a simple pushbutton wired to a GPIO, and if everything works as I like, I'd start to think about interfacing the real sensor.

mhelin
Posts: 127
Joined: Wed Oct 17, 2012 7:18 pm

Re: Connecting RockBand Drums to GPIO

Sun Feb 10, 2013 12:32 pm

Get this program working on RasPi:

http://code.google.com/p/sddm/

Another alternative is Hydrogen. These aren't only Linux samplers though.
http://www.hydrogen-music.org/hcms/node/29

Then get yourself the wireless receiver fro RB2 drums unless you already have that (see http://www.mattgrounds.com/rb2midi/).

Now combine the both parts, the interface and the program, and use some low-latency USB audio interface (E-Mu 0404 and Behringer models are reported to be working):

See this one on the RB2 interface:
http://lovehateubuntu.blogspot.fi/2008/ ... linux.html
http://lovehateubuntu.blogspot.fi/2008/ ... rt-ii.html
http://code.google.com/p/opendrums/

(small suggestion to all: learn to use google)

kfp
Posts: 4
Joined: Sat Feb 09, 2013 6:56 pm

Re: Connecting RockBand Drums to GPIO

Sun Feb 10, 2013 11:04 pm

killerbobjr:

Wow, that is extremely comprehensive. Thanks for taking the time to write all that out!

Here's how I see a single drum being wired (in such a way as to minimize work RP has to do):
[Piezo] -> [1/4" line] -> [analog filter] -> [analog trimmer] -> [A/D Converter] -> [RP]

If I understand correctly, the resolution of the A/D converter is what is going to determine how loud to make the audio sample? If I were to run a single A/D Converter for each channel am I talking about $1s for each or $10s or more? In this scenario how would I hook the A/D Converters to the RP? Is there some way to attach say 4 bits to the front of the signal (through the A/D Converter or another chip) so that I can read them on the software side to determine which channel the signal is coming from?

Should a DI box or preamp be enough to drive signal back up the snake in a live environment?

I'll definitely start with a USB adapter and work my way up. Thanks again for the essay!

karlkiste:
I think I'll try and start with an USB audio adapter. If that proves too much for me I'll try with a simple push button. Thanks for the response!

mhelin:
I think my mention of the Rock Band drums may have thrown you off a bit. I'm actually looking to create my own set (maybe using the Rock band cymbals since there don't seem too bad), probably following something similar to here: https://www.youtube.com/watch?v=SaqmgyEtdlU

If I end up trying to do more data processing in SW, then I might go to some kind of dual component setup, perhaps with 2 RPs or maybe another system, then MIDI in would be a good choice. I had not seen sddm before and that looks like it could be a good low processing power solution.

killerbobjr
Posts: 5
Joined: Thu Feb 07, 2013 6:44 am

Re: Connecting RockBand Drums to GPIO

Mon Feb 11, 2013 5:47 am

Since a piezo transducer has high output impedance, I would make the chain like this:

Piezo -> trimmer -> filter ->A/D -> Pi

The piezo also has very high output voltage compared to any EMS noise you may encounter, so I wouldn't worry about driving cables as long as you have a high input impendance trimmer, nor would I worry about cable capacitance which works to your advantage in filtering out high frequency noise.

Your A/D resolution has nothing to do with volume and everything to do with the difference between the loudest and softest strike. MIDI has 128 velocity levels. Very, very few people can distinguish between 16 velocity levels of atonal samples, let alone 128. An 8-bit converter will give you 256 levels. Divide that by 2 (for the positive and negative excursion of the signal) and you get 128 possible velocity levels, exactly enough for a MIDI drum sampler.

And to make your hardware design really easy, National Semiconductor (acquired by Texas Instruments) had you in mind when it made the ADC0816 16 analog multiplexed input, parallel data output converter ($15 at Digikey or Mouser). You have 13 pins that are necessary to interface with, (8 data pins, 4 multiplexer pins, 1 multiplexer address latch enable pin), plus 2 pins that will make your design simpler by using GPIO to control them (1 clock pin and one interrupt pin). This chip will allow you to design with a minimum of front end component parts.

Return to “Interfacing (DSI, CSI, I2C, etc.)”