Roland TD-15 MIDI read/write

It seems I had a request recently to improve my Roland TD-15 hack. And since I'm such a nice guy *cough* I figured I'll have a go at it... and behold the new version! It's pretty similar to the old one except that it now not only sends from the Roland to MIDI but also the other way around, i.e. it's "read / write".

Unfortunately the development didn't went as smooth as I hoped. Conceptually it was quite easy, just read from the MIDI device and pass that to USB via bulk data. The first annoying but was the fact that some programs send MIDI data in a somewhat shortened version which means you can't pass it directly but it needs some conversion. 

However that wasn't the bit I struggled with... reading from both MIDI and USB at the same time was. The first attempt was to fork the process and read USB in one process and MIDI in the other. While this worked in principle, it caused a weird issue, namely that the USB reading process would catch the result of the other process writing to the USB port. Which in turn locked up the device causing nothing to happen after that. What I don't get is that windows manages to send to the USB while listening to it uninterrupted. So probably the reading process is paused during the write... then again I haven't managed to convince LibUSB to do so...

Anyway as a result it's now a "polling" based driver which continuously checks the MIDI and the USB devices for new data and handles it accordingly. The obvious result is that it causes a somewhat heavy load and lags (a little)... then again I played around with Renoise and my TD-15 and I'm actually quite pleased with the results!

Enjoy, and keep the feedback coming!

Comments (5)

So thanks again for getting this midi thing to work! Really appreciate it.
I managed to compile your hack on a Raspberry Pi. The verbose mode worked fine, but the TD-15 wouldn't make any sound, even though it appeared to receive the midi notes. After a glance in the code I noticed something weird in the midi parser, so I changed the line 'switch(
)' for 'switch(
& 0xf0)' because TD-15 default listens to midi channel 10 (which would be a 9 in the second nibble) and that was the final step to get it working. Unfortunately the goal that I had in mind isn't viable, since the TD-15 doesn't play any other drum sounds than the sound that are assigned to the existing triggers, so my plan to add extra triggers over midi isn't going to work. Anyway, with the aforementioned fix it should work for most folks. For the RasPi it would be interesting to check out serialmidi / ttymidi to create a midi in port without USB midi cable. That would also solve the polling issues.
Off course I mean delayed instead of late.. lol
Sorry for the very late reaction, I got distracted by my other projects, but this sounds very promising. I'm going to try to compile it on a Raspberry Pi. Don't have a clue how to get a midi interface up and running up though..
Seems I found some well-hidden documentation on multi threaded async LibUSB coding:

XHTML 1.1 valid CSS 3.0 valid JavaScript 1.6 valid Vivaldi valid Os-linux valid Ws-apache valid Php valid Jas valid