Sunday, July 01, 2007

Whistling at your computer

Those of you following Slashdot would have noticed the IBM's article to provide commands to your computer by whistling at it. I decided to give it a shot on Ubuntu7.04. Follow these steps to get it working flawlessly on Ubuntu:
  • $sudo apt-get install libsndfile1 libsndfile1-dev libglut libglut-dev
  • Follow the instructions in the linked article and download the file
  • Replace the functions getEpochSeconds and getEpochMicroseconds in with this code:

    use Time::HiRes qw(gettimeofday); #Add at the beginning of the file

    sub getEpochMicroSeconds {
    my $seconds=0;
    my $microseconds=0;
    my $timeVal;
    ($seconds, $microseconds) = gettimeofday;
    $timeVal = $seconds.$microseconds;
    $timeVal = substr( $timeVal, 6);

    my $padLen = 10 - length($timeVal);
    $timeVal = $timeVal . "0" x $padLen;


    sub getEpochSeconds {
    my $seconds=0;
    my $microseconds=0;
    ($seconds, $microseconds) = gettimeofday;
    return $seconds

  • After this you can pretty much follow the same instructions that the article explains.
I tried running the few commands(did not try the windowing commands using xwit though) after which my mouth started to hurt and I could not whistle a consistent tune afterwards :( It's a good piece of software, and the sndpeek program that it uses is really awesome and feature rich but I think using whistle as an input is totally infeasible for me.
On the other hand, if you know how to play any kind of wind instrument(like flute, clarinet etc) you can easily write a superkewl password login utility that takes a particular tune as an input... sounds right out of a hollywood movie, doesn't it :)


  1. Well..dat is cool!!!! bt quite a task for ppl like me who cant whistle;-)

  2. WTF is this ?! Why to whistle when you have this thing called a keyboard in front of you which can be effectively used for the same purpose! Tomorrow I am gonna write a small script that would erase my hard drive when I turn the bathroom lights on

  3. @akansha: true.. i cant whistle consistently either.
    @bandan: well its called "letting the daemon loose" :P.. btw when you do that forward me the sourceforge project page :)