So, what’s always interesting to me is where we find our sources of inspiration. These can be a person, a book, a tweet, a website – anything at all. A lot of my project ideas start when I find something at the local car boot sale. If you follow me on Twitter you’ll already know my obsession with Robosapien robots!
Anyway, I was at the booty on Sunday, when this caught my eye…..
Ohh – It’s an Air Drum! 😀 Couldn’t really say no, especially for just £1. Not only did it have batteries in it – it worked too.
So this got me to thinking. I’ve been playing recently with the excellent Python cwiid library that lets you use Wii controllers with the Raspberry Pi. I’d only managed to ever get one controller working with a single Pi before so the first challenge was to get a pair of controllers working as the ‘sticks’ That took a lot of mucking about – until I found the excellent post by WiiGate that detailed how to set up 2 controllers properly using the MAC addresses. You can find it HERE.
I then found a bunch of open source drum samples which were available as .wav files – there are literally thousands of these out there to choose from. I wrote a small Tkinter app that displayed the position of the controller to give me an idea of the data that was being produced. Interestingly the position and accelerometer data is all wrapped up in one xyz Python tuple. This caused some confusion initially as if you move slowly from point A to point b this produces a very different reading than if the same movement is done rapidly. After playing around for a while (quite a long while!) I managed to map four distinct movements to four different drum sounds. I initially wanted to get 3 sounds on each controller but the movement scale was a bit too tight to do it successfully every time and 2 sounds often overlapped. So, I am using the trigger button combined with the movement for one of the sounds on each controller. This gives 6 different drums sounds, 3 per controller, that can be played without them overlapping.
I am fairly pleased with the end result! (Please excuse my total lack of rhythm)
(That boy’s got no rhythm!)
I’ve uploaded the Python script and drum samples to Github so you can have a play too….
Until next time…..