|
Hydrogen Forum >
Free zone >
"Rock Band" drums and Hydrogen
ckgreenman
Member
1 posts
04:29 GMT
21 February 2008 |
"Rock Band" drums and Hydrogen
Ok, so who else has tried this? I hooked up my Rock Band drums and managed to get them working to trigger Hydrogen. Granted the drum set is pretty limited but it's still pretty cool. For anyone else who might be interested, here is my setup and how I did it. Computer: Toshiba Satellite 1905-S303 Laptop OS: Linux (Ubuntu Gutsy 7.10 To start with I installed the ubuntustudio-audio meta package. This installs a bunch of audio production software among which, Hydrogen. It also installs a real time kernel but since it doesn't include drivers for my WiFi card I'm not currently running it. I then plugged my PS2 Rock Band drum set into the USB port. The Generic kernel recognizes it just fine and loads all the appropriate modules. The next thing I did was install joy2key. Luckily joy2key is in the Ubuntu repos so all you need to do is install it using apt-get or Synaptic Package Manager. Next I set up a simple .joy2keyrc file: ## .joy2kayrc ## START hydrogen -thresh 0 0 0 0 0 0 0 0 -X -buttons d c s x z From what I can tell, the thresh settings aren't that important. The -X options tells joy2key to bind to an X client window and the -buttons option assigns letters to the individual pads and the base drum pedal. The pads are assigned as follows: button 0: Blue button 1: Green button 2: Red button 3: Yellow button 4: Orange (foot pedal) Fire up Hydrogen and create a new drumkit. To make it easyI simply assigned the first 5 instruments as Kick, Snare, Hi Hat, Tom, Cymbal. These correspond to the key mappings above. Now run joy2key: joy2key -dev /dev/input/js0 -config hydrogen The dev option may be different on your system but on mine it was either /dev/input/js0 or /dev/input/js1. When joy2key runs it will ask you to click on the window where you want the signals to be sent. Simply click on the Hydrogen window and it should just start working. Enjoy!!! |
|
|
sam_the_wizer
Member
2 posts
17:31 GMT
10 March 2008 |
Sweet
I wanted to try this as well but don't own Rock Band (or a gaming console for that matter). I was looking for something a little more realistic than tapping my keyboard or electric piano for controlling drums in Hydrogen and thought this may be a good option. I really would like to make a full MIDI device, but my electronic tinkering skills are more on the analog spectrum. For now I plan on buying a cheap USB keyboard and rerouting circuits to triggers, but if anyone has a suggestion for making a midi interface at home, I'd be interested in hearing about it. |
|
|
gigadude
Member
1 posts
21:21 GMT
11 March 2008 |
cool...
I wrote a little ALSA app to do the same thing. Attachments aren't working so I've put it inline below (g++ -o rbd2midi_test rbd2midi.cpp -lasound to compile) - Ed // // rbd2midi - convert a Rock Band (tm) usb drum event stream to midi events // // example usage: // // > # start up rbd2midi // > rbd2midi & // Opened "Rock Band Drums" [129:0] // // > # find out the available ports: // > aconnect -i -o -l // // client 0: 'System' [type=kernel] // 0 'Timer ' // 1 'Announce ' // Connecting To: 15:0 // client 14: 'Midi Through' [type=kernel] // 0 'Midi Through Port-0' // client 128: 'TiMidity' [type=user] // 0 'TiMidity port 0 ' // 1 'TiMidity port 1 ' // 2 'TiMidity port 2 ' // 3 'TiMidity port 3 ' // client 129: 'Rock Band Drums' [type=user] // 0 'Rock Band Drums ' // client 130: 'Hydrogen' [type=user] // 0 'Hydrogen Midi-In' // // # connect to hydrogen (http://www.hydrogen-music.org/) // > aconnect 129:0 130:0 // #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <linux/joystick.h> #include <alsa/asoundlib.h> // this is the name that other apps will see static const char *my_name = "Rock Band Drums"; // for more printy goodness static const int verbose = 0; static snd_seq_t *seq_handle = NULL; static int my_client, my_port; static snd_seq_event_t ev; // by allowing the user to set these and doing a snd_seq_connect_to(...) // we could drive a midi synth directly (instead of needing aconnect) // for now just hard-wire us as a generic application input device static const int seq_client = SND_SEQ_ADDRESS_SUBSCRIBERS; static const int seq_port = 0; static const int chan_no = 0; // the following note values seem to work for hydrogen: static int orange_note = 36; // kick static int red_note = 40; // rock snare static int yellow_note = 45; // high tom static int blue_note = 46; // open HH static int green_note = 49; // crash // // close_sequencer - clean up and shut down // void close_sequencer() { if (seq_handle != NULL) { snd_seq_close( seq_handle ); seq_handle = NULL; } } // // open_sequencer - open the sequencer and advertise our midi input // int open_sequencer() { if (snd_seq_open( &seq_handle, "hw", SND_SEQ_OPEN_OUTPUT, 0 ) < 0) { fprintf( stderr, "Failed to open sequencer\n" ); return( 0 ); } my_client = snd_seq_client_id( seq_handle ); snd_seq_set_client_name( seq_handle, my_name ); //snd_seq_set_client_group( seq_handle, "input" ); my_port = snd_seq_create_simple_port( seq_handle, my_name, SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ, SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION ); if (my_port < 0) { fprintf( stderr, "Failed to create port\n" ); close_sequencer(); return 0; } printf( "Opened \"%s\" [%d:%d]\n", my_name, my_client, my_port ); return( 1 ); } // // flush_events - flush our event queue // static void flush_events() { snd_seq_drain_output( seq_handle ); } // // send_event - queue an event to go out of our midi port // static void send_event() { snd_seq_ev_set_direct( &ev ); snd_seq_ev_set_source( &ev, my_port ); snd_seq_ev_set_dest( &ev, seq_client, seq_port ); snd_seq_event_output( seq_handle, &ev ); // apparently you really need to flush each event?!? flush_events(); } // // hit_drum - generate a drum hit or release // static void hit_drum( int note, int is_hit, int vel ) { if (verbose) fprintf( stderr, "drum %d %s\n", note, is_hit ? "hit" : "off" ); is_hit ? snd_seq_ev_set_noteon( &ev, chan_no, note, vel ) : snd_seq_ev_set_noteoff( &ev, chan_no, note, 0 ); send_event(); } // // main - generate midi notes from joystick inputs // int main( int argc, char *argv[] ) { if (!open_sequencer()) return( 0 ); int fd = open( "/dev/js0", O_RDONLY ); if (fd < 0) goto Abort; // note sure this is necessary... snd_seq_ev_set_controller( &ev, 0, 0, 0 ); send_event(); snd_seq_ev_set_pgmchange( &ev, chan_no, 0 ); send_event(); snd_seq_ev_set_pitchbend( &ev, chan_no, 0 ); send_event(); flush_events(); while (1) { struct js_event e; while (read( fd, &e, sizeof(e) ) > 0) { const char *init = (e.type & JS_EVENT_INIT) ? "INIT:" : ""; const char *type = ((e.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) ? "BUTTON" : "AXIS"; if (verbose) printf( "time %d val %d type %s%s num %d\n", e.time, e.value, init, type, e.number ); if ((e.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) { switch (e.number) { case 0: // blue/square hit_drum( blue_note, e.value, 127 ); break; case 1: // green/X hit_drum( green_note, e.value, 127 ); break; case 2: // red/O hit_drum( red_note, e.value, 127 ); break; case 3: // yellow/triangle hit_drum( yellow_note, e.value, 127 ); break; case 4: // orange (kick) hit_drum( orange_note, e.value, 127 ); break; } } } flush_events(); } Abort: if (fd >= 0) close( fd ), fd = 0; close_sequencer(); return( 0 ); } |
|
|
pablomme
Member
54 posts
11:42 GMT
13 October 2008 |
It works great! For convenience, I've attached a script that does all the joy2key stuff automatically. You'll need to install joy2key and gmessage, then edit the script and change the two lines at the top to point at your hydrogen binary and to an h2song to load with an appropriate layout of your choice. Then run it and drum away. BTW, I had problems with synchronization/real-time sound. Solved by choosing ALSA in Hydrogen and creating a ~/.asoundrc or /etc/asound.conf containing: # Allow multiple streams with sensible period/buffer settings pcm.dmixer { type dmix ipc_key 1024 slave { pcm "hw:0,0" period_size 256 buffer_size 1024 } # Use bindings to speed things up (apparently) bindings { 0 0 1 1 } } # Redefine default pcm device pcm.!default { type plug slave.pcm "dmixer" } # OSS compatibility pcm.dsp0 { type plug slave.pcm "dmixer" } ctl.mixer0 { type hw card 0 } # This is probably useless pcm.card0 { type hw card 0 } |
|
|
Annoying Twit
Member
5 posts
18:06 GMT
15 February 2009 |
Of of those R.A. Penfold books has a circuit etc. for making a MIDI controller using a PIC (single chip computer). But unless you enjoy things like that, probably better to buy one. A MIDI keyboard with velocity will do, and can be quite cheap. I've got one of these: |
|
|
thagoat
Member
1 posts
23:26 GMT
12 March 2009 |
What??!!
Has anyone tried this with the xbox 360 set? I might have to just try it myself! |
|
|
dr.Smit
Member
1 posts
03:28 GMT
13 March 2009 |
Buy discount no prescription drugs,sale 40-60%
Great site. Good info the best online pharmacy KLIK HERE:<a href=http://nmser.com/>online pharmacy for lowest prices!</a> |
|
|
macinnisrr
Member
1 posts
22:15 GMT
13 August 2009 |
Ubuntu Mod
Gigadude: your code works great, but on Ubuntu systems (since intrepid at least, maybe earlier, and perhaps other systems), one has to replace "/dev/js0" with "/dev/input/js0". Also, pablomme's joy2key script works well, but on my wireless rock band drums, the word "Drum_kit" has a lower case k on kit. I just removed the part that says "_kit" in the script so it should work with any kind of usb drums now, although I have zero programming experience so I might be wrong. I'm going to do a bit of fiddling around and see if I can make an executable that combines the features of these two posts, eg: checks to see whether a rock band kit is connected, and only then runs the rbd2midi stuff. I think this would especially help with people on varying distributions as well as solve the problem that arises when one has a game controller on /dev/input/js0 and the drums on /dev/input/js1 (or other) Thanks again for the wonderful work guys, this is one of the coolest features I've seen in a long time!!! |
|
|
byolcay
Member
4 posts
20:45 GMT
6 October 2009 |
cam balkon
cam balkon katlanır cam balkon sistemleri mega cam balkon tarafından uygun fiyata kaliteli ve g?venilir bir şekilde yapılır cambalkon denince akla gelen ilk isim megacambalkon katlanır cambalkon piyasasında oncu kuruluş http://www.megacambalkon.com |
|
|
byolcay
Member
4 posts
20:47 GMT
6 October 2009 |
boya ustası boyacı ustası
boya badana ustası duvar boyacısı boyacı usrası http://www.boyaciveysel.com |
|
|
byolcay
Member
4 posts
20:48 GMT
6 October 2009 |
dusakabin dus kabini
dusakabin firması arpesdus http://www.arpesdus.com |
|
|
gilead
Member
1 posts
18:19 GMT
5 December 2009 |
Guitar Hero drum kit
Thanks for sharing the info ckgreenman! I just tried the same with Rock Band drums with Ubuntu 9.10 and, well, everything works just fine :) The startup procedure is a bit clumsy but at least it's a start. Here's my .joy2keyrc file (the key bindings are pretty random and should be modified to one's preferences): START hydrogen -thresh 0 0 0 0 0 0 0 0 0 0 0 0 -X -dev /dev/input/js0 -buttons b x n g z j I've had to fiddle a bit with button mappings, here's how Guitar Hero pads seems to be mapped to joystick buttons: button #1: blue button #2: green button #3: red button #4: yellow button #5: pedal button #6: orange so to map e.g. X keyboard key to green pad you put 'x' at the second position in -buttons line. |
|
|
bigZ23
Member
1 posts
13:12 GMT
15 January 2010 |
Got the drums working - just need some help
Guys, you won't believe my luck. I picked up from toy's r us (aus) for $30aus a rock band drum kit for my son....... Saved about $100au it was cool. So about 10 minutes after the initial environmental setups - hydrogen, joy 2 key I'm making drum sounds ( I won't say beats coz i'm rhythmically "challenged" my son is a cracker tho.) Now i'm the Linux guy of the house and i'm wondering how to use the automated script or ( I get an error on line 23 ./play_drums: line 23: gmessage: command not found So I'd love to know how I can make it just so my son can click on a launcher(script) and have him drumming away. Could someone pleeeeeeasse help me Thanks guys, you guys rock (excuse the pun) |
|
|
bdub777
Member
1 posts
23:33 GMT
26 March 2010 |
re: Hydrogen Forum > Free zone > "Rock Band" drums and Hydrogen usb issue
i got the programs to operate however mu usb wont recognize the drumkit |
|
|
|