Kent West wrote:
Hey folks!
Apologies for the very off-topic post; I've been googling for the answer
off-and-on for two days unsuccessfully, so I've finally decided to turn
to the smartest group of people around.
I want to write a basic little Morse Code key program to put into the
newsletter of the local amateur radio (ham) club. It'd be nice if it
were cross-platform, and preferably easy-peazy on Linux and maybe just
as easy on OS/X and just a little more trouble on Windows (so I can
subtly suggest that Windows is sub-standard to nix-based OSes (okay, I'm
never subtle about pushing Debian to my fellow hams)), and it'd be ideal
if the code requires almost no overhead, so non-programmers can easily
grasp how it works.
All I want to do is to detect two keys, say the left- and right-shift
keys, or the < and > keys. For one key, a short "dit" audio tone would
be generated, and for the other key, a longer "dah" audio tone would be
generated. I need to bypass the keyboard buffer, so that holding down
the dit key for two seconds doesn't generate 30 dits; it should produce
dits while the key is held down, but once the key is let up, the dits
should immediately stop (after finishing the one it's on).
The code would look something like this:
While ( not ESC)
read keystroke
if keystroke = LeftArrow then generateTone(dit)
else if keystroke = RightArrow then generateTone(dah)
Done
I'm sure the information is out there on Google, but not being a
programmer, I'm finding snippets that don't have enough context for me
to be able to actually test (for example, I found a Java snippet that
looked promising, but I couldn't even get it to compile), or the
snippets read from the read-ahead keyboard buffer which introduces
delays and run-ons.
So, any suggestions as to which language will be best suitable for my
wants?
Any suggestions as to how to detect the keypress in that language?
Any suggestions as to how to generate a tone in that language (this one
I figure will be fairly easy to Google for, but I haven't tried, seeing
as the keypress has been the show-stopper so far).
IFAIK you've hit upon the one problem in cross-platform programming,
access to the speaker for variable duration (dit and dah).
I would use Qt and that makes keypresses easy to detect, but not sound
of variable duration, unless you don't mind recording a dit.wav and a
dah.wav and then the problem is easy again.
I have done what you want but only for Linux because the basic
pc-speaker sound producing algorithm (ioctl) is different from M$.
Debian has Package: beep (1.2.2-20) but that uses ioctl to access the
speaker.
Hugo
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]