public class MorseDecoder
extends java.lang.Object
We begin by classifying regions of the Morse code file as tone or silence. This requires binning the file and computing power measurements for all of the samples that fall into each bin. The BIN_SIZE parameter controls how long each bin is.
The next step is to classify each bin as tone or silence. The POWER_THRESHOLD parameter controls this cutoff. We combine this with looking for runs of tone or silence and classifying them as dot (short run of tone), dash (long run of tone), or space (long run of silence, equivalent in length to dash). (In real Morse code there are also longer runs of silence that separate words, but we'll ignore them for now.) DASH_BIN_COUNT controls the cutoff between dots and dashes when considering tone, and is also used for spaces when considering silence.
At this point we have valid Morse code as space-separated letters! So the last step is to look up each symbol in a table and return the corresponding letter value.
Constructor | Description |
---|---|
MorseDecoder() |
Modifier and Type | Method | Description |
---|---|---|
static void |
main(java.lang.String[] unused) |
Main method for testing.
|
static java.lang.String |
morseWavToString(WavFile inputFile) |
Convert a WAV file containing Morse code to a string.
|
public static java.lang.String morseWavToString(WavFile inputFile) throws java.io.IOException, WavFileException
This function brings everything together: the binning, the power thresholding, and the final Morse to alphanumeric conversion.
inputFile
- the input file to processWavFileException
- thrown if there is a WavFile-specific IO errorjava.io.IOException
- thrown on other IO errorspublic static void main(java.lang.String[] unused)
Takes an input file from the user and tries to print out the Morse code by processing the file using your code above. You should feel free to modify this, as well as to insert additional print statements above to help determine what is going on... or what is going wrong.
unused
- unused input arguments