Creating A Morse Code Trainer
Even with the advent of digital communications Morse Code still remains alive and well in the world today with Ham radio operators, but even so it also is a form of emergency communication that can be of use in all sorts of situations. The famous S.O.S., associated with such phrases as "Save Our Souls" or "Save Our Ship" is the Morse code distress signal. The current form of morse used and known most of the world over came about in 1912 with the ratification of the International Morse Code. Global Maritime Distress and Safety System has replaced the use of Morse Code at sea with even more sophisticated transmission systems, however; the S.O.S. (actually written with a bar over it) is still a recoginized emergency visual, radio, and audio signal.
The Morse Code Trainer has three different versions of code including the current International Morse Code (ITU), set as default; American or Railroad Morse, the original version created by Samuel Morse and Alfred Vail for use with their invention, the electric telegraph and Continental. American has been implemented using current Morse Code patterns of International since the true American had several other additions which made it more difficult to learn and use. Continental Morse Code is also represented here which was used for a brief time in Europe. Of Note: the American / Railroad Morse is built using the International algorithms, since as mentioned before, the American made use of a long and longer dash as well as a long pause between elements. Current International Morse is based on "Dit" - dot and "Dah" - dash only. The "Dit" and "Dah" as it is best to learn and is actually the way it sounds over a communication relay; have a simple algorithmic relationship. The "Dit" length is roughly 1200 / Words Per Minute rate; the "Dah" is three times the length of the "Dit". Pause between characters is the same as a "Dah" or "Dit" times three and finally the pause between words is seven times the "Dit" length.
Using the Words Per Minute slider sets the all the correct timings. It ranges from very slow, five words per minute; to 75 words per minute. After that I believe the sound quality of the audio engine makes it difficult to make out anything faster. The Morse Code Trainer uses a couple of third party tools. The main tool is NAudio NAudio is used to create the Morse .MP3 message file as well as providing playback functionality. NAudio also provides a waveform visualization and spectrum analyzer. The Waveform Timeline comes from The Wpf Sound Visualization Library, which by the way has all the library functions needed to make your own custom MP3 player. Lame is used to convert .MP3 files to .WAV.
Originally I tried the Console.Beep function which Microsoft touts has the ability to do set frequency and intervals. Nope. Sound is bad and the duration is not fine tuned enough to produce a quality Morse Code message. Going straight to the Kernel32.dll and calling Beep(int frequency, int duration) provided some improvement, but still the quality was very poor. Thus NAudio was used to create the message. Due to the header file format of an MP3 / WAV file I had to create each piece, "Dit", "Dah", and pauses; as individual WAV files, then used a merge function to assemble all the component WAV files into one file. This final WAV file is converted to an MP3 for playing since NAudio only provides playback functionality with MP3 files.
End Of Line Man!