->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 4: Song Generator

Winter 2003-2004
Objectives Addressed
  • Understand and apply complex data structures and algorithms.
  • Use appropriate algorithms (and associated data structures) to solve complex problems.
  • Be able to use data structures in software design and implementation.
  • Be able to apply the STL in software design.
Procedure

Write a program that will generate a number of songs. The first song should consist of a random number of notes in a random sequence. The duration of each note should be randomly selected from the following list:

Duration Probability
x/16 y/16
x/8 y/8
x/4 y/4
x/2 y/2
x y
2x y/4
4x y/16

where x = 250 ms and y is the probability of selecting a note with a duration of 250 ms, i.e., it should be twice as likely to select a duration of 250 ms than a duration of 125 ms. No song should be more than 5 minutes in length.

The second song should contain all of the same notes as the first song, only the notes should be in a scrambled order.

The third song should contain all of the same notes with the order of the notes progressing from shortest to longest and lowest to highest.

The fourth song should be exactly the same as the first song only one octave higher.

The fifth song should be exactly the same as the first song only each note should be replaced with a triplet of notes going in sequence from the same note an octave lower, the same note, and the same note an octave higher. The total duration of the triplet of notes should be the same as the original note.

Your program should also produce a histogram indicating how frequently the various durations occurred within the song. The histogram should look something like this:

x/16: *
 x/8: **
 x/4: ****
 x/2: ********
   x: ****************
  2x: ****
  4x: *
Constraints
  • Your song should not be off pitch. The following table lists the frequencies for on pitch notes. Multiplying or dividing the frequency by a power of two will produce a note that is one or more octaves higher or lower respectively.
    Note Frequency (Hz)
    A 220
    A# 233
    B 247
    C 262
    C# 277
    D 294
    D# 311
    E 330
    F 349
    F# 370
    G 392
    G# 415
  • Select an appropriate data structure to store the notes in your song.
  • Make use of the following generic algorithms in the STL:
    • random_shuffle
    • transform
    • count_if
    • sort
  • Make all necessary modifications to your Note class from lab 3 to make it work with the above generic algorithms.
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:

  • Narrative including:
    • Your analysis of the advantages and disadvantages of generic algorithms. Were they appropriate for this project?
    • A list of changes you needed to make to your Note class and why those changes were needed.
  • Sample results: include the five .wav files and the histogram for your favorite song produced by your program. Be sure to name these files 285MSOEloginL4x.wav where MSOElogin is replaced by the login name of the partner who submits the report and x is replace with a, b, c, d, or e.
  • A summary of your activity log indicating how much time you spent on the assignment (following the template provided in the lab4.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 was originally developed by Dr. Darrin Rothe and modified by Dr. Chris Taylor.

Last Updated: Wednesday, 14-Jan-2004 10:32:19 CST