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.

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 Lab7 IntelliJ Project

We’ve set up an Lab 7 GitHub repository containing an IntelliJ Project that’s correctly configured for Lab 7. 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.

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:

  1. How do we distinguish between tones and silence?

  2. 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.

  3. 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 7 documentation.

Most importantly, have fun! When you are done you should be able to decode 1.wav and 2.wav. Then take a stab at HW0.wav, which you decoded previously as part of our early homework assignment. That file is a bit different than the others, and you may find that you need to fiddle with your parameters a bit to get it to work.

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.

CS 125 is now CS 124

This site is no longer maintained, may contain incorrect information, and may not function properly.


Created 10/24/2021
Updated 10/24/2021
Commit a44ff35 // History // View
Built 10/24/2021 @ 21:29 EDT