CSCE 145: Homework 9

A Low-Pass Sound Filter

Objectives

In this assignment you will learn about

Program Specification

The purpose of this assignment is for you to learn about sound waveforms and how to process them, which is known as digital signal processing. Your program will read a sound waveform from a file, encoded in the .wav format, apply a low-pass filtering algorithm to the waveform, and write the result to a new file. You should try various amounts of filtering and listen to the results.

Create a project in Eclipse for this assignment. Download the zipped file here SoundStuff.zip and unzip its 8 files into the src folder that Eclipse created for your project. (In eclipse, you will see all of these files in the folder "(default package)"). Next, download the class Example.java and also store it in the src folder of your project. Look at the code and try to understand how it works, so that you will be able to modify it for your own purposes.

A low-pass filtered version of the sound can be created by replacing each sample by the average of its neighboring samples. I suggest you try ~21 samples. Specifically, have your program create a new Sound object having the same length as the original one and set each sample sound2.setSampleAt(n, avgValue) to be (sound1.getSample(n) + sound1.getSample(n+1) + ... + sound1.getSample(n+20) )/21

By using an average, the waveform is smoothed out, which removes the highest frequencies. The lowest frequencies are unchanged, i.e., the filter passes the low frequencies and removes the high ones. You shold be able to hear the difference. Here is a bit of a song by the German singer Nena on which you can test your algorithm "Tokyo" by Nena. Here is a stereo version that sounds better, but only one channel will be affected by the code in Example.java and it is difficult to hear the changes. Save the two .wav files in the folder having the name of your project (not in its src subfolder).

Include a method that will draw a simple graph using JFrame of 100 points of a sound waveform. Apply the method to the first 100 values in the original music and then to the first 100 values in the filtered music.

Upload your source code to the dropbox at https://dropbox.cse.sc.edu.