Invisible Piano (Keyboard Anywhere, a Kinect Piano)





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

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.



    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Spotless Contest

      Spotless Contest

    We have a be nice policy.
    Please be positive and constructive.




    Thanks for the writeup. What is the difference between libfreenect, openkinect and the software you used in your other tutorial? I have a Kinect, want to hook it up in Linux and interact with it using Python. I thought libfreenect is the best way to do this?

    Hi, im not sure if someone can help me with a problem... at the moment when i try to use "sudo apt-get install pyqglviewer" i can't download the packages so i try to install it manual but have problems too. I appreciate if someone can help me with that

    Lenin, Did you get this sorted out?

    Im using raspbian jessie 4.4

    Hi everyone, I have installed everything except the extra .deb file because I do not know how to deal with libexpat dependency which I have fulfilled in my Ubuntu 12.04. I have this problem :

    terminal output: transform loaded from file


    a blank untitled window output

    May I know why ?

    I've very sorry. All the software in this instructable is a year and a half old, and most of it has been updated since I posted this. Since I haven't kept up on new Kinect software since I wrote this up, I'm not sure how everything interacts with all of the new software.

    Please ensure you're following the OpenKinect's read me/install files and that you're installing all of the dependencies. Other then that advice, I'm not going to be any help.

    I have used Instructable website to get an idea to my project which was very useful to us.
    My project is Invisible Piano Keyboard anywhere
    I downloaded all the software needed as well as the hardware, but I have the following error whenever I tried to run it:

    Could you help us please
    Thank you in advance

    Error: Invalid index [0]
    Error: Can't open device. 1.) is it plugged in ? 2.) Read The README
    Tracback (most recent call last ):
    File "" , line 286, in animate depth,
    timestamp = freenect.sync_get_depth()
    TypeError: 'NoneType' object is not iterable
    could not claim interface on motor: -6

    I'm sorry, I haven't used the application in long enough that I couldn't say what might be wrong. It kind of sounds like you're missing a dependency though. Make sure you install all of the required items first.

    I really appreciate you posting this here, it's quite an amazing feat.
    Just wanted to let you know, the install for python-dev did not work for me.
    This was on a brand-new install, so it might be broken for everybody. It gave me the following error message on 12.04 Precise:

    The following packages have unmet dependencies:
    python-dev : Depends: python2.7-dev (>= 2.7.3) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

    Now, I've tried to get the packages they depend on, (python-dev -> python2.7-dev -> libexpat1-dev [ Depends: libexpat1 (= 2.0.1-7.2ubuntu1.1) but 2.1.0-1ubuntu1 is to be installed {I have no idea why this is happening}] -> libexpat1 [which I have already]) and looked all around to try to fix this (especially the "broken packages" part, and tried a reinstall of all my packages after purging), maybe python 2.7.3 is no longer supported on 12.04 (as newest python is 3), but I have little idea. The strange thing is, I got it working before, but I ignored all the warnings and proceeded with the next step anyway. After trying to install GTK3+ (I wanted to try compiling some source code for a 3d-modeling program), my Ubuntu install broke for whatever reason (wouldn't even get to login screen), and I don't want to go through that again.

    I'm an Ubuntu noob (trying, though). Could ya help a brother out? Please email me at if you or anybody is having the same problem and found a solution, or the possibility of a solution.

    Thanks, again.