->Homepage
->Schedule
->Courses
-->CS182
-->CS183
-->CS285
-->Tentative Schedule
-->Objectives
-->Homework
-->Quiz 1
-->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
-->Lab 5
-->Lab 6
->STL Help
->Book Errata
->Course Policies
->Electronic Submission
->Documentation Standards
->Old Exams
->C++ Examples
->MSVC++ Info
->Software
->Support Forum
->Unix Info
->Nature Photos

[Home]
[Rich][Home][Rich]
[Author]
CS285 -- Lab 3: Guitar Simulator

Winter 2003-2004
Objectives Addressed
  • Understand and apply complex data structures and algorithms.
  • Use appropriate algorithms (and associated data structures) to solve complex problems.
  • Have a thorough understanding of the Standard Template Library.
  • Be able to use data structures in software design and implementation.
  • Be able to apply the STL in software design.
Requirements

You are to write program with a command line interface that will generate .wav files. The command line options are as follows:

  • -rev infile.wav
    Should generate infileREV.wav which should be the infile.wav file in reverse. Any additional command line arguments should be ignored if this one is present.
  • -pluck outfile.wav
    Should generate a simulated guitar pluck using the Jaffe-Smith algorithm (described below). The frequency, length, and sampling rate of the pluck should be determined by the following parameters:
  • -samp samprate
    Specifies the sampling rate used. (Default: 11025 Hz)
  • -decay decrate
    Specifies the rate of decay (should be between 0 and 1). (Default: 0.99)
  • -notes frequency1+length1 frequency2+length2 ...
    Specifies the sequence of notes to be generated by the Jaffe-Smith algorithm. Each frequency(Hz)/length(ms) combination specifies one guitar pluck. This command line option must always be the last option and may contain an arbitrary number of notes. If the option is omitted (and the pluck option has been selected, the program should generate on 262 Hz guitar pluck for 2 seconds.
Details

I would suggest making use of the utility classes developed by Dr. Fred DePiero for reading and writing .wav files and refined by Dr. Eric Durant. An example of how to use the classes is available from my examples webpage.

In your implementation of the -rev option, you are required to make use of the STL stack class. In your implementation of the -pluck option, you are required to make use of the STL queue class. The Jaffe-Smith algorithm is described below.

You must create a Note class that describes each guitar pluck.

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();  // Notice that this is not the correct
  data2 = que2.dequeue();  // function call for the std::queue class
  sample = decrate * (data1 + data2) * 0.5;
  que1.enqueue(sample);
  que2.enqueue(data1);
  write 32000*sample to .wav file (assuming 16 bit data)
}

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

Just for fun (optional)

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 5 lab)

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

Your report should include:

  • Narrative including:
    • Your reaction -- convince me that you were thinking while working on this project.
    • A brief description of any problems you encountered or questions you have regarding the lab.
    • A discussion of how you worked together as a team.
    • Any suggestions you have for how the lab assignment could be improved.
  • Sample results:
    • Results of using the -rev option on this (ominous.wav) file. Be sure to call this file 285MSOEloginL3a.wav where MSOElogin is replaced by the login name of the partner who submits the report.
    • Results of running your program with the following command line parameters:
      lab3 -pluck 285MSOEloginL3b.wav -notes 262+200 524+200 262+40
      where MSOElogin is replaced as instructed above.
    • [Optional] some interesting result called 285MSOEloginL3c.wav along with the command line arguments that produced the file.
  • A summary of your activity log indicating how much time you spent on the assignment (following the template provided in the lab3.xml template document). Please use the following categories:
    • Design
    • Coding
    • Debug (before you think it's working)
    • Test (after you think it's working)
    • Documentation
    • Other
  • Note: You should be working together the entire time on this project so your table should mainly contain "both" entries. If you both spent one hour debugging your code together, your activity log should indicate one hour (not two hours) was spent debugging.
  • The Documented source code for your program.

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: Wednesday, 07-Jan-2004 11:32:38 CST