Class MorseDecoder
- java.lang.Object
-
- MorseDecoder
-
public class MorseDecoder extends java.lang.Object
Decode Morse code from a WAV file.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 Summary
Constructors Constructor Description MorseDecoder()
-
Method Summary
All Methods Static Methods Concrete Methods 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.
-
-
-
Method Detail
-
morseWavToString
public static java.lang.String morseWavToString(WavFile inputFile) throws java.io.IOException, WavFileException
Convert a WAV file containing Morse code to a string.This function brings everything together: the binning, the power thresholding, and the final Morse to alphanumeric conversion.
- Parameters:
inputFile
- the input file to process- Returns:
- the decoded Morse code from the WAV file as a string
- Throws:
WavFileException
- thrown if there is a WavFile-specific IO errorjava.io.IOException
- thrown on other IO errors
-
main
public static void main(java.lang.String[] unused)
Main method for testing.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.
- Parameters:
unused
- unused input arguments
-
-