Making music using a computer, Wiimote and PureData

An article that appeared on the Create Digital Music website, about making music using the WiiMote and a computer, drew my attention. Several hints were given on the how to, but as always in doing new things the information was scattered everywhere and nowhere. After reading many articles and watching many videos I found out how to realize a working setup for myself. In this article I’ll try to explain the steps needed to create a working setup for yourself.

Prerequisites (what you need to get it working):

  • Hardware
    • Computer
    • Bluetooth adapter (an adapter for using an open wireless protocol for exchanging data over short distances).
    • Wii Remote (also known as a wiimote, the primary controller for Nintendo’s Wii console)
  • Software
    • Ubuntu Studio (a multimedia editing/creation flavor of Ubuntu. It’s built for the GNU/Linux audio, video, and graphic enthusiast or professional)
    • Pure Data (a real-time graphical programming environment for audio, video, and graphical processing)
    • Wiilib (a library of externals enabling you to use a Wii remote controller in Pure Data)
    • CWiid(a collection of Linux tools written in C for interfacing to the Nintendo Wiimote)
    • Pure Data programs to combine all of them resulting in sound creation.

Let’s get going:

Where possible I provided links to the necessary download locations.

You either have an pre installed bluetooth adapter in your computer or you can buy one in the shop.

Download the Ubuntu Studio 9.10 (Karmic) DVD Image and burn it to DVD.

Repartition your hard disk (or don’t), and install Ubuntu Studio 9.10

Make sure you’ve got batteries Wii Remote

Open a terminal session in Ubuntu then copy and paste the following instructions:

sudo apt-get install libcwiid1 lswm wmgui wminput

Sometimes it comes in handy to know your gear so at this point, you can turn on the Wii remote to scan by pressing 1 and 2 simultaneously (all the lights will flash) then running:

hcitool scan

After you installed the necessary packages, you we’ll be able to give it the first shot by entering wmgui in a terminal window

wmgui

Select “connect” from the file menu, press 1+2 on the Wiimote when prompted then click OK. Lights and rumble can be turned on and off from the controls menu, and which inputs are displayed from the settings menu. Using this, you can test the IR camera (I didn’t have infrared lights so I used a candle (BE VERY CAREFULL WITH OPEN FIRE IN AND AROUND YOUR LIVING AREA not to set the place on fire)), the accelerometers and check the inputs from the Nunchuck or Classic Controller.

Now you know basic set-up is working (your computer running Ubuntu Studio, your bluetooth adapter, your Wii Remote and the “connection” between it all).

Getting the Wiimote working with Pure Data

Copy wiilib.pd_linux (alternative download: wiilib.pd_linux_i386 here or the amd64 version wiilib.pd_linux_amd64 here

sudo move /home/winko/Downloads/wiilib.pd_linux /usr/lib/pd/extra/.

Start up PureData and edit the start up parameters to PD by adding “wiilib” to the “PD binaries that need to load” (“File” >> “Startup…”).

Close pure data and start up “Jack Audio Connection Kit”.

Start PureData again and if all went well you’ll see the following message.

Connect to Pure Data to Jack by going to “Media” and select “Jack” you will see the image below. Click “OK”.

Now we need to get the sound out of Jack… Go to the “Jack Audio Connection Kit”. Select “pure_data_0” on the left and select “system” on the right than press the “Connect” button. After that it should look like this.

Now we’re ready to load a Puredata program to test our setup, it is called wiimote-help.pd (alternative download here). Go to “File” and “Open” in Puredata and select the program called wiimote-help.pd and follow the instructions on the screen. IN ORDER TO CONNECT: First put the wiimote into discover mode (press buttons 1 and 2 simultaneously) then click the flag/button/message called “discover”. Select the reportAcceleration flag/button/message and start shaking your big bad Wii Remote. If all went well you’ll see the green acceleration sliders move.

Ok assuming that this went well we can start an actual sound program, in the example below I used  wii_plink.pd (alternative download here) (wii_plink.pd comes with the needed sinegrain.pd make sure they are both in the same directory). Go to “File” and “Open” in Puredata and select the program called wii_plink.pd. IN ORDER TO CONNECT: First put the wiimote into discover mode (press buttons 1 and 2 simultaneously) then click the flag/button/message called “discover”.

Now when your shake your Wiimote nothing happens until you select the “compute audio” toggle button in the main Pd window.

Now you should have sound coming out of your speakers, have fun!

Suggestions for improving this article are welcome!

If you created or know different Wiimote enabled Pure Data sound programs, then please let me know and drop me a line.