Introduction: Invisible Piano (Keyboard Anywhere, a Kinect Piano)

About: Matthew was previously a STEAM integrator with a private K-8 school. He loves taking things apart to see how they work, and will sometimes put those things back together. Much of his time is spent working with…

After writing my previous instructable, I was asked about installing some slightly different software to use with the Kinect. Since I'd already done it, I figured it wouldn't take to long to retrace my steps and write the instructable. After much frustration, I figured out a really easy process to get everything installed and talking.

This instructable with walk you though getting a virtual keyboard working with the current release (11.04) of Ubuntu.

There are other ways of doing this (which I've done in the past), but trying to reaccomplish the task, I found many shortcuts to what I did in the command line previously.

If you have any questions on the command line or getting around in Ubuntu, please see my previous instructable. In this instructable I will assume you have a basic knowledge of the system and how it works. Like my last instructable terminal commands will be given starting with $. Do not copy the $ when transposing.

Also, don't transpose anything to terminal between [ ], it's there for reference.

Step 1: Materials

Computer - with a fresh Ubuntu install
Spare Time

Step 2: Install Ubuntu

For this, I opted to use the newest release of Ubuntu: 11.04.

I downloaded and installed the 32 bit version onto my laptop, then used Update Manager to update the system (there was a couple hundred megs worth of updates).

Bonus info:
For this release, Ubuntu decided to ditch Gnome and move to Unity, their out User Interface.

Like any new system, if you haven't used it before, it's going to take some getting used to.  I can say after using it for a while, getting pissed and moving to Debian (and Gnome 3) for a while, then coming back and trying it again, it's not that bad.  It's not my first choice in desktops, but that's because it's different that what I'm used to and is going to take me some time to come around. The important bit is that it works, it's useable, and the design is such as to try to make it as user friendly as possible.

With that in mind, if you need help finding your way around, check this out for how to update, install software, etc.

Step 3: Open Kinect

After the system is installed and the updates are complete, The first program you're going to need is OpenKinect.

They have excellent instructions on their webpage to get this installed: click here, and follow the Ubuntu Manual Install instructions.

When you're finished with this step, your Kinect should be visible on your computer.

Step 4: Python

The Keyboard Anywhere script is written in Python, which OpenKinect can't deal with in its regular installed state.  Happily, there is a Python Wrapper that allows the two to work together.

Thankfully, when you installed OpenKinect in your last step, it downloaded the python wrapper on your computer. The problem is that while it downloaded, it didn't install.

If you go to your home (where home is your username) directory: home/libfreenect/wrappers/python you'll see the information about the wrapper.  You can open the README to see instructions on installing.

For ease of time and those who like to copy-paste
$ sudo apt-get install cython python-dev python-numpy   [these need to be installed before we can install the python wrapper]

Navigate your way, in terminal, to the python folder. If you close and open terminal:
$ cd libfreenect/wrappers/python

and then install:
$ sudo python install

** Instruction addition as per tdinsmoor in the comments below **
If you are having dependency issues with libexpat1-dev (on Ubuntu 12.04), you'll need to download and install a separate .deb package to fix it.
For AMD64 systems:
For i386 systems:

Ubuntu software center may give you an error at first, but ignore this and proceed to install python2.7-dev and python-dev with:
$ sudo apt-get install python-dev python2.7-dev

The packages should now install correctly, and you may proceed to install the wrapper.

Step 5: Keyboard-Anywhere - Dependencies and Downloads

The python script for Keyboard Anywhere can be found at that link.

All the information below can be found by reading the README provided in the package you can download at the previously mentioned link.  There are some discrepancies in the instructions provided which I have fixed for this instructable.  (i.e. pyqt4-devtools should read pyqt4-dev-tools and fluid-soundfont-gm doesn't require install because it's part of the fluidsynth package) I've also left out dependencies that have been installed in previous steps.

So before we move on, let's deal with some more dependency issues!

$ sudo apt-get install pyqt4-dev-tools qt4-qmake libqt4-dev python-qt4-gl python-qt4-dev python-setuptools fluidsynth
(if you're asked for special permissions during the install, just click yes)

Finally, if you haven't yet, click downloads at the top and click tar.gz
-unpack it onto your computer where ever it downloaded (I will assume it's the Downloads folder)

If you scroll to the bottom you'll see links to download both QGLViewer and PyQGLViewer
-We're going to skip this for now.

Step 6: QGLViewer and PyQGLViewer

The instructions given in the Keyboard-Anywhere README for installing these files, is difficult at best, nightmarish at worst.  Instead of following those directions, I've opted to install it a completely different way.  You can find my instructions at this link.

$ sudo add-apt-repository ppa:christophe-pradal/openalea
$ sudo add-apt-repository ppa:christophe-pradal/vplants
$ sudo apt-get update
$ sudo apt-get install pyqglviewer

If you want to downloaded and install QGLViewer and PyQGLViewer manually, after downloaded and unpacking the files, ensure you complete the following steps to correct errors that will come up.

Navigate to /home/Downloads/libQGLViewer-2.3.9-py/QGLViewer/

Open in gedit (or whatever default application may open in)

Go to the file drop downs:
  -Go To Line
  -enter 201

Now, I'm not sure if this is the proper way to fix this error, but it works. Change the line that reads:
system( g++ --version | grep " 3\.2\.0 " > /dev/null )|system( g++ --version | grep " 3\.3\.1\-2" > /dev/null ) {
system( g++ --version | grep " 3\\.2\\.0 " > /dev/null )|system( g++ --version | grep " 3\\.3\\.1\\-2" > /dev/null ) {

One of the only forums I could find that was helpful was this one. If you try to progress in these steps, you'll get that error.

I will not be providing any more directions on manually installing QGLViewer and PyQGLViewer. If you'd like to manually install them, follow the directions in their README/INSTALL files.

Step 7: PyFluidSynth

FluidSynth, for some reason, doesn't play nice with the python scripts that are trying to use it.  To fix this, I installed pyFluidSynth. It seems to work nicely.

Download pyFluidSynth
Unpackage in your downloads folder
Navigate in terminal to unpacked folder and install

$ cd Downloads/pyFluidSynth-1.2.4
$ sudo python install

Step 8: Enjoy!

Everything is now installed, all you have to do is run Keyboard Anywhere.

Navigate to the appropriate directory, and run using the python command.

You need to use sudo, or you don't have enough permissions to do everything.
Unfortunately I've found that sudo, and su both have a timer on them. So after 30-45 minutes, you'll need to close the program and start it up again. I haven't found a way around this yet.

$ cd Downloads/petermoz-keyboard-anywhere-2a8b9ed
$ sudo python

The README that is associated with the downloaded Keyboard-Anywhere file has detailed instructions on what to do once running.
If you're comfortable editing python script (it's not too difficult after it's already been're just changing things), you can open the file in gedit and change the size of the keys and link to different sound files.

If you have any questions or comments, feel free to leave them below.