Intro: How to Control Your Computer With Sonar
Step 1: What Is Sonar?
Sonar is a means of emmitting sound pulses and listening for echos. Submarines use sonar to detect objects so they can navigate through the water.Now that that's out of the way, let's figure out how to incorporate this into our computer.
Step 2: Putting Sonar on Your PC
If you go to steve tarzia.com, you'll find a sonar program that you can download and install for free. This program uses your computers speakers and microphone to emit sound pulses and listen for echoes to detect whether or not you are sitting in front of the computer. So if you move away from your computer, the sonar will detect it and will automatically put your computer to sleep. While this program is pretty incredible on it's own, the website also gives you the source code so that you can edit and tweak the program and make it do whatever you want with your computer, which is what we'll be doing in the next step.
Step 3: How to Edit the Source Code
NOTE: If you're not a programmer, then you probably don't want to try this, as it can be pretty difficult. But if you know what you're doing, then just download and extract the source code from the steve tarzia site to a folder called "sonar_dist".
In order to edit and compile it, you'll need a few things first:
- Begin by downloading Visual C++ Express 2008, which Microsoft offers for free.
- Then you also want to download and install wxWidgets version 2.8.10.
- Lastly, you'll need to download PortAudio and extract it to your "sonar_dist" folder using 7zip.
Step 4: Cleaning the Source Code
Once you have all that installed, open up your wxwidgets folder and go to "build" and then "msw". Double click on the file called "wx.dsw". Then click Yes To All. Now go to "Build" > "Clean Solution". And when it's through go to "Build" > "Build Solution" and wait for it to finish. And once it does finish go double click on wx_dll.dsw and repeat the same process.
Step 5: Editing the Source Code
Now go into your "sonar_dist" folder and double click on "sonar.vcproj". You should be able to click on the debug button to launch the sonar program. So now if you want to change what the program does, you can double click on "SysInterface.cpp" and under the "sleep_monitor/platform windows" boolean, you can change the PostMessage to any other c++ command you want. For instance, this command will open up the CD tray:
mciSendString('set CDAudio door open", NULL, 0, NULL);
and this command will open up a website:
ShellExecute(NULL, "open", "http://www.tinkernut.com", NULL, NULL, SW_SHOWNORMAL);
You can view the video above for what the examples look like. Have fun experimenting with this one!