Project: Program a Song

Overview

Working in pairs, you will develop a program that makes the Scribbler 2 robot play a song or melody that lasts at least 30 seconds. Within the program, printed text will introduce the song (e.g. by title and composer). You may not use the songs from class examples or labs.

Before you start this assignment, take a look at the grading criteria, which are listed at the bottom of the page.

Submit your work by:

  1. Email a copy to csc161-02-grader@grinnell.edu - be sure to include any test plans and a statement about why you think the program is correct.
  2. Print a copy to hand in before class on the due date. Make sure everyone signs the Academic Honesty Statement. I have included some instructions for printing from the command line.

Details

Song Choice

You may work with a song that you have found elsewhere (giving appropriate credit), or you may create your own song. Creativity in identifying a song or melody is encouraged. You may not use any songs which have been used in examples or labs. (If you do not read music, please see me. We can pick a very simple tune, and I can help you identify the pitches.)

Song Introduction

Information (e.g., title and composer) about the song should appear in the opening program header AND printed to the terminal. If the song was written by someone else, the header should give a reasonably complete citation, while the printed introduction may be more concise.

Program Structure

Use a separate file to define the notes used in the song. For example, if the music utilizes a Western, well-tempered note pattern, the program might include scale-notes.h.

Music usually provides a structure for sound, and your program should reflect this structure. For example, many songs contain several verses with a refrain or chorus that is played after each verse.

Your program must contain at least 5 functions in addition to main. One of them should play the entire song.

Some functions should specify the notes (e.g., calls to rBeep) for smaller parts or phrases of the song. The beginning of each of these functions should include a print statement, so the workstation will display what part of the song is being played (e.g., "phrase 1", "line 1", "chorus", etc.).

At least one function should represent a collection of phrases or lines (e.g., "verse 1", "part 1", "entire song").

Of course, each function should include a descriptive header, indicating what part of the music is played by that function.

The main procedure should be reasonably short—just setting up the pieces (e.g., connecting to MyroC), calling one function to play the song, and wrapping up (disconnecting from MyroC).

Constants

In this project, you will call rBeep with many different values, for example:

rBeep (0.25, 698);
rBeep (0.125, 698);
rBeep (0.25, 698);
rBeep (0.25, 698);

However, this is not readable because these numbers appear to be magic. Why did we choose 0.25 and 698 as the arguments to rBeep? To make sense of these values and avoid repetition, we used "constants" to give these kinds of values names in scale-notes.h. You can do the same for note durations.

const double note8 = 0.125;
const double note16 = 0.0625;
Using these constants makes code more readable.
rBeep (note8,  pitchF5);
rBeep (note16, pitchF5);
rBeep (note8,  pitchF5);
rBeep (note8,  pitchF5);

You should use constants whenever appropriate in your program to make it more readable. When in doubt, if you have a "magic number" that has some additional meaning than just, e.g., 5, then you should enshrine that knowledge as a constant.

 

Grading

Submit your work by:

  1. Email a copy to csc161-02-grader@grinnell.edu - be sure to include any test plans and a statement about why you think the program is correct.
  2. Print a copy to hand in before class on the due date. Make sure everyone signs the Academic Honesty Statement.

In addition to the General Programming Style Guidelines (which applies for every programming project) for evaluation of style and readability, the project is worth 25 points.

Points for poor style may be deducted from this score.

The section entitled "Constants" is a derivative work of Scribbler Song, by Titus Klinge and Peter-Michael Osera, used under a Creative Commons Attribution-NonCommercial 4.0 license.