in reply to Morse code via sound card input

The code I used to generate the Morse is below: (I got it on the net, the sox line is to convert to unsigned wav for the Audio::Wav object in the Freqext module of toma)... it may have flaws as you point out :-) Also I did some sprintf rounding to make the timestamp and frequencies more readable.... the timestamps are actually more accurate.
#!/usr/bin/perl -w use Audio::Data; use Audio::Play; my $freq = 400; my $dot = 0.07; my $dash = 3*$dot; my %morse = ( A => '.-', B => '-...', C => '-.-.', D => '-..', E => '.', F => '..-.', G => '--.', H => '....', I => '..', J => '.---', K => '-.-', L=> '.-..', M => '--', N => '-.', O => '---', P => '.--.', Q => '--.-', R => '.-.', S => '...', T => '-', U => '..-', V => '...-', W => '.--', X => '-..-', Y => '-.--', Z => '--..', 1 => '.----', 2 => '..---', 3 => '...--', 4 => '....-', 5 => '.....', 6 => '-....', 7 => '--...', 8 => '---..', 9 => '----.', 0 => '-----', ' ' => ' '); my $au = Audio::Data->new(rate => 8000); sub morse { my ($au,$s) = @_; while (length $s) { my $sym = $morse{uc(substr($s,0,1))}; if (defined $sym) { while (length($sym)) { for (substr($sym,0,1)) { $au->tone($freq,$dot) if (/\./); $au->tone($freq,$dash) if (/-/); $au->silence(3*$dash) if (/\s/); } $au->silence($dot); substr($sym,0,1) = ""; } $au->silence($dash); } substr($s,0,1) = ""; } } foreach (@ARGV) { morse($au,$_); } my $svr = Audio::Play->new; $svr->play($au); open(F,">out.au") || die; $au->Save(\*F); close(F); system("sox out.au -u data/out1.wav");

But as I was trying to think of ways to overcome all these obstacles, the thought occurred.... why even use Morse? Frequency Shift Keying (30 different frequencies, separated by 250 Hz), with each freq assigned a letter or punctuation mark, would be so much more reliable, faster, and easier to decode with digital audio analysis.

I guess old Morse still has its uses though.


I'm not really a human, but I play one on earth. Cogito ergo sum a bum