|
CSE Home | 326 Home | About Us | Search | Contact Info |
Project 1 - Sound Blaster!Due: Friday January 13
Make sure you go through General Policies, Grading Policies and Programming Guidelines before you begin working on the project. In particular, note that the writeup you turn in is worth a substantial portion of the grade! OutlineIntroductionThe purpose of this project is to implement a Stack ADT in the two most common ways, a static array and a linked list. Your Stack implementation will be used to do sound manipulation, namely reversing a sound clip. This tool was used by musicians including the Beatles, Jimi Hendrix and Ozzy Ozbourne, although it seems to have fallen out of favor in recent years. "But wait," you say, "CSE 143 never taught me how to work with music..." Don't worry! Most of the hard work has already been done. The AssignmentYou will write a program that will take a sound file in the .dat format (explained below), and output another .dat sound file which is the reverse of the first. We provide you with a class Reverse which reads in a .dat sound file, puts the sounds values on a stack, pops them off in reverse order, and puts these reversed values in a new .dat sound file. We've also provided you with a DStack interface, which defines a stack that holds double values. Your first job is to look over these files and become familiar with them.Now for the work! You need to provide two stack implementations, one using an array and the other using a linked list. They should be called ArrayStack and ListStack, respectively. They should implement the interface DStack, which we provide to you. Once you provide this implementation, Reverse should work and create backwards sound files. It shouldn't take more than a page or two of code to provide the implementation. Your array implementation should hold around a million elements. The Reverse program takes 3 arguments. The first is either array or list, and specifies which implementation to use. The next two are the input and output .dat files (you need to provide the .dat extension). Running the program will depend on your system; from the command line it will look something like the following. java Reverse list in.dat out.datIn an IDE there is usually a dialog for setting program parameters which contains a field for the program arguments. Read the section on Digital Sound to learn how to create a .dat file. To get you started, we've created a .dat file here. For details on what to turn in for this assignment and how, read the section on Logistics. For a quick reminder of how interfaces work in Java, see Java Reminder.
In addition, answer the following questions and provide the answer in
your writeup.
Going Above and BeyondThe following list of suggestions are meant for you to try if you finish the requirements early. Recall that any extra-credit points you earn for these are kept separate from your assignment score and will be used to adjust your grade at the end of the quarter, as detailed in the course grading policy.
Logistics for Project 1
How Digital Sound WorksWe will view sound as a continuous function of time from the positive real numbers (time) to the interval [-1.0, 1.0] (amplitude). Since a computer can't "hold" a function defined on the reals, we have to approximate the function. We do this by measuring (or "sampling") the sound several thousand times per second. This process is called "Analog to Digital Conversion", or ADC. The
number of times per second the sound is sampled is called the sample
rate and is measured in Hertz. For example, CDs are recorded at
44100 samples per second, or 44.1kHz. Wait a minute! Is this the right
class? I thought this was CSE326.
Yes, this is CSE326. The only sound file format you need to know about is the .dat format described below. You don't even have to know very much about that either, as we're giving you the code that reads and write that format. In order to play sounds you produce, you need a way to convert the .dat file into a format that common media players (Windows Media Player, winamp, RealPlayer, etc.) understand. We'll describe one way to do it below; however, you're free to use any converter you can find. There is a windows version of sox available at SourceForge. It seems to work well, but download and run at your own risk. It is also a command-line program and works in the same way as the UNIX version described below. sox is a UNIX command-line utility whose name stands for "SOund eXchange". It allows you to convert between many different sound formats including .wav, .au, etc... In particular, sox allows you to convert to and from .dat sound files. .dat files are cool because they are human-readable, text-based, sound files. Note that you will need to perform this conversion to answer one of the writeup questions. The general strategy is as follows.
If you get a command not found error when trying to do the export mentioned above, it's probably because you're in the tcsh shell. Given your TAs unfamiliarity with that shell, the easiest thing to do is type bash to enter the bash shell, at which point the export command should work as advertised.
That's all there is to it! But before we get too excited, let's first explain...
The .dat file format starts with one line describing the sample rate of the sound file. This line is required. The rest of the file is composed of two columns of numbers. The first column consists of the time (measured in seconds) when the sample was recorded, and the second column contains the value of the sample, between -1.0 and 1.0. Here is the beginning of a sample .dat file. Notice that the numbers in the first column increase by 1/44100 each step. This is because the sample rate is 44.1kHz. ; Sample Rate 44100
Here is the same file, a little deeper on: 0.22693878 -0.0062561035
Note that for this assignment, you shouldn't have to deal much with the .dat file yourself, as the provided Reverse.java does all the lifting for you. All you have to do is implement the stacks. We are telling you the format because it will be helpful for you to write a short file by hand to run, to verify if your program works. Java ReminderFor this assignment you will need to instantiate an interface, DStack, in two different ways. The DStack interface defines a simple stack:interface DStack { boolean isEmpty(); void push(double d); void pop(); double top(); }To implement this interface, write a class as follows. class ArrayStack implements DStack { public ArrayStack() { // Your constructor } public boolean isEmpty() { // Your isEmpty() } public void push(double d) { // Your push() } // continue with the rest of the functions, // along with any member variables, etc. };The ListStack class should be defined similarly. AcknowledgmentsLike many assignments, this has been passed down to us through the vaporous mists of time. Among all our fore-bearers, we would especially like to thank Ashish Sabharwal, and Adrien Treuille and his Data Structures professor, Timothy Snyder. |
Computer Science & Engineering University of Washington Box 352350 Seattle, WA 98195-2350 (206) 543-1695 voice, (206) 543-2969 FAX [comments to cary] |