Morse Coding
In this lab we’ll do a small programming project start to finish. Our task today brings together many of the concepts that we’ve discussed in class this semester—data representation, loops, arrays, and algorithms. It’s not done in Android, but it’s still fun, and may give you some ideas for your final project.
1. Written Exercises (30 Minutes)
We begin with a short warmup designed to familiarize you with the key concepts that we’ll be using in the coding portion of the lab.
Complete this part of the lab in pairs using Google Docs. Create a copy of our document template, and then edit it to record you and your partner’s answers. Note that you must open this document using your @illinois.edu Google Apps account. We will not grant access to non-Illinois users.
Have a course staff member check your answers as you go. When you are done, move on to the next section.
2. Programmatic Decoding (60 Minutes)
Computer scientists are a resourceful and creative bunch 1. And one of the things that we hate doing is doing things that computers do better—which tend to be repetitive and dull anyway.
Why should I sit there with a pen and paper listening to Morse code and trying to decode it? I can teach a computer to do that, and then it’ll do it all day, all night, without errors, until the end of time. That sounds like a lot more fun than doing it myself—so let’s give it a shot. It turns out to be not so hard.
2.1. Forking and Cloning the Lab8 IntelliJ Project
We’ve set up an Lab 8 GitHub repository containing an IntelliJ Project that’s correctly configured for Lab 8. Getting access to it is similar to how you imported MP0. But you have to fork our repository first. If it’s not obvious how to do that, try following these instructions.
Note that we return (temporarily) to IntelliJ for Lab 8. Please don’t try and complete the programming portion using Android Studio.
2.2. Our Approach
This may seem like a daunting task at first, but let’s break it down into its component parts.
We know that Morse code consists of tones of different lengths separated by silence. That naturally leads to several questions:
-
How do we distinguish between tones and silence?
-
Once we can do that, how do we distinguish between long tones (dashes) and short tones (dots). We also need to be able to detect long periods of silence which are used to separate characters.
-
Once we can do that, how do we translate things from Morse code to alphanumeric characters?
We’ve provided some starter code to get you going, and in particular to help you pull audio samples out of the WAV file. Use that as a starting point, and work on each of the subproblems above. You’ll probably find it helpful to draw pictures and compare code with other partner groups—this is completely legal for this lab. At intervals the course staff will pause and go over a solution to each of the steps outlined above.
You will want to understand the WavFile
library that we provide.
Here is some documentation
by the original author,
and we also have
our own package documentation
available online.
You may also want to review the
Lab 8 documentation.
Most importantly, have fun!
When you are done you should be able to decode 1.wav
and 2.wav
.
3. Help with MP4 (20 Minutes)
Use any remaining time in your lab section to get help with MP4. If you are finished or far along, please help others—but help them learn, don’t just give them the answers. And if you are behind, please reach out the course staff for help.