Skip to content

Control your home devices by whistling

April 1, 2012

This post will show you a simple application of the USB enabled remote control.

The major problem of all kinds of physical remote controls is that they are usually not ready to hand when you need them. If you have to move to get to the remote control, you could as well directly switch on the device. Thus the whole concept of ‘remote control’ is becoming a bit useless. Therefore this post will show you how to create a non physical remote control.

The idea of the non physical remote control is very similar to the clapper switches. But instead of clapping you simply whistle. Whistling has some advantages over clapping. The first and most obvious is that you do not need your hands for whistling. You can continue doing what you are doing and control devices in parallel. The second more important advantage is the expressivity of whistling. You can vary your whistles in the rhythm, the length and the tone whereas you can vary claps only in the rhythm. This expressivity allows you to encode specific commands like “turn desk lamp on” or “turn ceiling light off” and so on.

To whet your appetite, here is a video showing the non physical remote control in action:

So how does this work? Actually it is very simple. A microphone captures audio inside my room. This audio is transformed by a FFT into its spectral components. The FFT gives you the information of the magnitude of the captured frequencies. Inside this frequency representation of the microphone signal we have to look for whistle signals. And in fact, whistle tones have two properties making them very easy to detect. First, they are loud. Thus the magnitude of whistle frequencies will be quite high. Second, whistle signals are very close to single frequency signals (like a perfect sine signal). The following three images will give you an impression on the spectrums captured from the microphone. The x axis describes the frequency, the y axis describes the magnitude of the frequency component.

The spectrum of a whistle sound with no background noise looks like this:

As you can see the whistle sound should be easy to detect. The sharp spike indicates that the whistle is very close to a single-frequency sine.

If we add a little music as background noise, the plot looks like this:

Still, the whistle is clearly visible.

Having a high detection rate is nice. But also the false positive rate should be as low as possible. Lets take a look at a graph of someone talking near to the microphone:

Here we see several spikes. To avoid the highest spike from being detected as a whistle, we introduce a uniqueness ratio. This ratio is defined by the maximum value divided by the second maximum value. In case of the voice graph the uniqueness ratio would be very low, approximately 1.5. In contrast to that in the case of whistling with background music, we have a uniqueness ratio of >8. This filter is very simple but yet effective. The independence of amplitude values let the filter work on loud whistling and soft (far away) whistling without adapting the filter parameters.

You find the implementation of the whistle detector in my mercurial repository in the folder linux/whistle_control . To check out the repo, execute

hg clone https://bitbucket.org/befi/remote-controlled-socket

For running the code you need to have installed the fftw3 development headers (libfftw3-dev for Ubuntu) and the ALSA development headers (libasound2-dev for Ubuntu).

Please note that this code is not really polished. It is a 1h quick hack but it should give you the basis for more advanced implementations. Currently the program only distinguishes between two commands. The relative frequency of two whistle sounds determines which command is executed. low to high => command 1, high to low => command 2. However, this should be easy to adapt to your needs.

About these ads

From → Uncategorized

25 Comments
  1. This is great! If I find time I’m going to build something like this myself. I can think of tons of uses for something like this.

  2. pixelport permalink

    Awesome! Keep it on!

  3. eparis permalink

    Very nice. Something that you could look into if you are interested in removing the PC out of the equation, i.e. doing everything with an embedded circuit, is the approach that this guy used to detect claps:

    http://petemills.blogspot.com/2012/01/clever-clapper.html

    It uses a filter and analog comparator and then feeds that digital output into a microcontroller.

    • Thank you for that tip! It looks like an interesting project. I’ve chosen the dockstar mainly because I wanted to have easy networking access to the remote control. That way I can control the devices by an App from my smartphone. I also use it as my alarm. The cron tab on the dockstar starts in the morning to switch on my desk lamp, followed by the ceiling lamp and finally the amplifier will switch on and play some music.
      The whistle project started afterwards as a “wouldn’t it be cool if…?” project. And actually, it works now better that I thought it would.

      • The quick code you made could be turned into something standalone that reads a config file to execute arbitrary things (since the sending strings to /dev/ttyUSB0 is specific to your particular needs). If it were blackboxed like that, you’d find people using in shell scripts all over the place. I know I would!

      • Mh, that sounds like a good idea. Maybe I’ll hack something together in that way. Thanks for the comment!

  4. Samus permalink

    i would pay for this. i will pay for this, if someone would like to build it for me

  5. Oh, you inventors. Look, I really think stuff like this is cool, but you folks need a bit more capitalistic drive. Have a few prototypes ready for sale on eBay or Amazon. I’d gladly pay for one and leave my comments for others.

  6. In fact, forget about config files and anything else complicated. If your program just streamed out numbers indicating whistle frequencies like
    100
    134
    121
    93

    as they’re heard, script writers could catch the stream and write lots of useful stuff that noticed time delays, pitch differences, etc.

  7. This is great! And I can think of tons of uses for something like this.
    But I am doing this by using the Matlab. So do you think it is working well by using the Matlab? Thank you

    • I don’t know about the live audio recording functionality of matlab but the signal processing is easy to do with it. If you managed to port this to matlab, please give me a note so that I can link to your implementation!

Trackbacks & Pingbacks

  1. Whistle controls for you home electronics - Hack a Day
  2. Whistle controls for you home electronics » Geko Geek
  3. Whistle controls for you home electronics » Dirty Old Device
  4. Whistle controls for you home electronics « Hackaday « Cool Internet Projects
  5. Whistle controls for you home electronics | ro-Stire
  6. Make A Whistling-Powered Remote Control | Lifehacker Australia
  7. Make a Remote Control for Your Home Devices That You Operate By Whistling [Video] | tylor.co
  8. Whistle controls for you home electronics | CisforComputers
  9. USB Enabled Remote Control | HACKOLOG - Amazing Hacks and Mods
  10. Hacks and Mods: USB Enabled Remote Control - Meed Tech
  11. Hacks and Mods: USB Enabled Remote Control
  12. Turn your amplifier on whenever something starts to play on your ALSA soundcard | befinitiv

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: