CPSC 170 Sub Post Lab 8
Karplus-Strong
Due Before Class on Friday, March 16th

The post lab 8 assignment involves creating stringed instument music synthesizer. Sounds on computers are represented as a series of descrete samples. The Karplus-Strong algorithm heuristically generates samples that model a simple stringed instrument. For this sub-post-lab assignment you will implement a method that generates samples using the Karplus-Strong algorithm. The Karplus-Strong algorithm computes a new sample as the average of the first two elements. The new sample is scaled by a decay value (a value between 0 and 1) and then added to the end of the buffer. Finally, the first element in the buffer is removed.

The file KarplusStrongString.java contains a class that represents a string on a musical instument, such as a harp, piano, or guitar. It has a LinkedList of Doubles instance variable that is a buffer of samples. The class also has a constructor that takes an array of samples and initializes the sample buffer with them. For this assignment complete the sample method. This method should update the sample buffer according to the Karplus-Strong algorithm and return the sample that was removed from the buffer.

Include in your code submission a program that tests your sample method. The program should create a KarplusStrongString with a non-random array of doubles. It should repeatedly print the result of calling the sample method and the expected result. You should calculate the expected result on paper (keep the input fairly small and simple so that it is not hard to compute). Also be sure to test special cases.

Submission: Submit your code as a zip file with your name as the zip file name on the course Inquire site.