CS2851 -- Lab 3: Guitar Simulator

Fall 2005
Objectives Addressed
Requirements
Before the end of the first lab period (30 points)

You should write a program that will read in a .wav file and write a .wav that is the contents of the first file, only backwards (you may choose to play the reversed sound to your computer's audio system in addition to writing it to a file. Your program should make use of the java.util.Stack<E> and/or java.util.Queue<E> classes.

You should demonstrate this program to your instructor before the end of the first lab period. Be prepared to answer questions and explain your source code. You will not be required to submit your source code or a report for this portion of the assignment.

The rest of the assignment (70 points)

You are to write a program that will generate .wav files that simulate the sound generated by plucking a guitar string. Your program should make use the the Jaffe-Smith algorithm to produce the sound.

You should be able to specify the filename, sample rate (default: 8000 Hz), decay rate (between 0.0 and 1.0, Default: 0.99), and one or more notes where both the frequency and duration are specified. Note: each note specifies one pluck that should be generated by the Jaffe-Smith algorithm. You must create a Note class that describes each guitar pluck.

Details

You may find the Java Sound Demo and JS Resources examples useful. I have provided a WaveFileExample class that makes use of the JMusic package (jmusic.jar) and the javax.sound.sampled.* classes to read and play a .wav file.

Jaffe-Smith Algorithm

Information on the Jaffe-Smith algorithm (which is based on the Karplus-Strong algorithm) is available here. Here is pseudocode for the algorithm:

enqueue N random numbers between -1.0 and 1.0 into que1
enqueue one 0.0 into que2
repeat the following M times:
{
  data1 = que1.dequeue();
  data2 = que2.dequeue();
  sample = decrate * (data1 + data2) * 0.5;
  que1.enqueue(sample);
  que2.enqueue(data1);
  write sample to .wav file
}

where N = sampleRate/frequency and M = length*sampleRate.

Just for fun (optional)

Your team may decide to make an interactive version of this program (e.g., display a guitar fret on the screen and produce sounds immediately whenever the user clicks on the fret.)

Here is a sample waveform produced by one team from a previous quarter that got a bit carried away on this assignment. Knock yourselves out (but make sure you do the base requirements first).

Lab report (due 11:00pm, the day prior to week 7 lab)

Here is a template file to use as a starting point for this report.

Your report should include:

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the XML help video and/or sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost. It may be wise to keep a diskette backup as well.

Your grade will depend on quality of design, clarity of code and documentation, as well as whether your program produces the correct results. If you have any questions, consult your instructor.

Acknowledgment

This assignment, inspired by a similar assignment by Timothy Snyder, was developed by Dr. Chris Taylor and is based on the Jaffe-Smith algorithm. (See D.A. Jaffe and J.O. Smith in: "Extensions of the Karplus-Strong Plucked-string Algorithm," Computer Music Journal, 7(2), 1983, pp. 56-67.

Last Updated: Tuesday, 11-Oct-2005 16:25:14 CDT