Poor Man's Theremin
If you're interested in gaining some experience playing the theremin but don't want to spend a lot of money or build the kit, try the “Poor Man's Theremin” (PMT), written by Seth David Schoen.
The PMT turns a laptop computer with an 802.11b card into a theremin-like instrument, using the signal strength reported by the card to control the pitch of a note. To try it, first compile this C program, called ttone, using the command cc -o ttone -lm ttone.c.
#include <math.h>
#include <linux/kd.h>
const int A = 440;
const float r = 1.05946;
int pitch(int base, int observed){
return (int) A * pow(r, (observed-base));
}
int main(int argc, char *argv[]){
int base, observed;
if (strcmp("off", argv[1])){
base = atoi(argv[1]);
observed = atoi(argv[2]);
ioctl(0, KIOCSOUND, 1190000 / pitch(base, observed) );
} else {
ioctl(0, KIOCSOUND, 0);
};
}
Put the ttone executable in a directory that's in your PATH.
Now run the following shell script, called pmt.sh, and move into range of an 802.11b access point. You can change the pitch by moving closer to or further away from the access point or by moving your hand over the 802.11b antenna in a theremin-player-like manner.
#!/bin/sh
# Poor Man's Theremin
m=100
oldQ=foo
[ $1 ] && m=$1
while :
do
Q=$(iwconfig 2</dev/null | grep Link.Quality | cut -d: -f2 | cut -d/ -f1)
if [ $oldQ != $Q ]
then
./ttone $m $Q
fi
oldQ=$Q
done
The Poor Man's Theremin does not have the volume control of a proper theremin, and the pitch changes in discrete steps instead of continuously. Implementing these features is left as an exercise for the reader.
Don Marti is editor in chief of Linux Journal.
email: dmarti@ssc.com
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- 100% disappointed with the decision to go all digital.
- Linux--The Internet Appliance?
- Kernel Korner - The New Work Queue Interface in the 2.6 Kernel
- Kernel Korner - I/O Schedulers
- UpFront
- Readers' Choice Awards 2011
- Why Python?
- Real-Time Linux Kernel Scheduler
- Solaris-Zones: Linux IT Marbles Get a New Bag
- You Need A Budget





3 hours 38 min ago
4 hours 1 min ago
4 hours 3 min ago
6 hours 26 min ago
7 hours 55 min ago
10 hours 56 min ago
12 hours 45 min ago
12 hours 55 min ago
12 hours 58 min ago
13 hours 19 min ago