Assignment 5: The Music Editor:   First Movement
1 Editing Music
1.1 Some background on music
1.2 How is music written?
1.3 What should the music editor eventually look like?
2 Assignment
3 Grading standards
4 Submission
6.7

Assignment 5: The Music Editor: First Movement

Due: Fri 10/21 at 8:59pm; self-evaluation due Sat 10/22 at 8:59pm

This assignment is to be completed solo. Subsequent homeworks will be done in pairs. Start looking for partners now, and email Sam Berin (berin.s@husky) with both your usernames. You will not be able to submit subsequent homeworks until we create a team for you on the handin server.

1 Editing Music

Your goal in this series of homework assignments is to construct a music editor in the classic Model-View-Controller architecture. This week’s assignment is to construct the model for your editor. There is no starter code for this assignment. You need to design, implement and test your model from scratch...without knowing precisely what the view or controller will need from you.1You also may not personally know much about musical notation or theory. That is not actually an impediment to implementing these assignments: just be careful and methodical about your design, based on the information here.

Please place all your code in the cs3500.music.model package.

1.1 Some background on music

Distilled to its mechanical essence, music is simply playing a collection of tones for varying durations on various instruments at various volumes at varying times. Each tone is called a pitch, and there are twelve distinct pitches in the Western system of music. The thirteenth pitch “sounds the same” to our ears, and so we say it is the “same” pitch in a different octave.2This is the so-called “chromatic scale”. Other musical systems use a five-pitch-per-octave, or pentatonic, scale (common in Asian music); others use twenty-four (common in Slavic music); still other systems forego obvious note names entirely (common in African music). We give these notes names:

C C♯ D D♯ E F F♯ G G♯ A A♯ B

and the note after B is again C. (I am simplifying the names of the notes here; the note C♯, pronounced “Cee-sharp” is the same note as “Dee-flat”, written D♭; notes without these “accidentals” are called natural. Those of you familiar with piano keyboards will note that the white keys correspond to the natural note names, while the black keys correspond to the sharps.) Typical human hearing can detect about ten octaves of notes. For example, so-called “middle C3So named because it’s roughly in the middle of most people’s speaking voices. is the fourth octave people can hear, and thus written C4; the note fifteen notes higher is D♯5. You can, of course, just label every note by a number, but names are ever so much easier to read and remember.

In addition to pitch, notes have a duration. Typical pieces have a rhythm to them, called a measure, that is usually three or four beats long. (Most pop, rock, or hip-hop music is typically four beats per measure; some classical forms such as waltzes are three beats per measure.) A note’s duration is measured in beats, and can in general be any integer multiple of any integer power of two beats long. A “quarter note” is one beat long (and is 1/4 of a 4-beat measure); a “half note” is two beats long (half of a 4-beat measure); a “whole note” is a full measure long. There can also be eighth notes (half a beat), sixteenth notes (1/4 of a beat), etc. For this assignment, you may simplify your model and only represent notes that are an integral number of beats long.

When no notes are playing, we say the music has a rest, which is likewise measured in beats.

Music also has dynamics describing how the volume changes during the performance of a piece. For now, you can ignore dynamics, and consider everything to be played at a constant volume.

Some music is very simple, and consists of at most one note played at a time — a single person singing a single melody, for example. Most music is more complex, with multiple notes (of possibly different durations) played simultaneously.

1.2 How is music written?

Some ideas:

Other operations are surely possible.

1.3 What should the music editor eventually look like?

Shown here are two screenshots of a possible music editor view that you might write. In both images, higher pitches are higher vertically, and time increases to the right. Every row is a particular pitch, and beat numbers are marked at the top. Vertical bars mark measure lines every four beats:

In the first image, the onset of a note is drawn black, while all remaining beats of the note are drawn green. In the second, all beats are drawn blue, and the notes are shortened ever so slightly to distinguish one long note from several adjacent shorter ones. (Additionally, notes in the “current beat” are drawn in cyan, but you can ignore that fact in this assignment.) When you design your own views, you may choose whatever visual styling you wish, so long as the information is clear.

Here is an alternate view of the same piece, rendered as text in the console:

╔══════════════════════════════════════════════════════════════════════════════════╗
║    E3   F3  F#3   G3  G#3   A3  A#3   B3   C4  C#4   D4  D#4   E4   F4  F#4   G4 ║
║ 0                 X                                            X                 ║
║ 1                 |                                            |                 ║
║ 2                 |                                  X                           ║
║ 3                 |                                  |                           ║
║ 4                 |                        X                                     ║
║ 5                 |                        |                                     ║
║ 6                 |                                  X                           ║
║ 7                                                    |                           ║
║ 8                 X                                            X                 ║
║ 9                 |                                            |                 ║
║10                 |                                            X                 ║
║11                 |                                            |                 ║
║12                 |                                            X                 ║
║13                 |                                            |                 ║
║14                 |                                            |                 ║
║15                                                                                ║
║16                 X                                  X                           ║
║17                 |                                  |                           ║
║18                 |                                  X                           ║
║19                 |                                  |                           ║
║20                 |                                  X                           ║
║21                 |                                  |                           ║
║22                 |                                  |                           ║
║23                 |                                  |                           ║
║24                 X                                            X                 ║
║25                 |                                            |                 ║
║26                                                                             X  ║
║27                                                                             |  ║
║28                                                                             X  ║
║29                                                                             |  ║
║30                                                                             |  ║
║31                                                                             |  ║
║32                 X                                            X                 ║
║33                 |                                            |                 ║
║34                 |                                  X                           ║
║35                 |                                  |                           ║
║36                 |                        X                                     ║
║37                 |                        |                                     ║
║38                 |                                  X                           ║
║39                 |                                  |                           ║
║40                 X                                            X                 ║
║41                 |                                            |                 ║
║42                 |                                            X                 ║
║43                 |                                            |                 ║
║44                 |                                            X                 ║
║45                 |                                            |                 ║
║46                 |                                            X                 ║
║47                 |                                            |                 ║
║48                 X                                  X                           ║
║49                 |                                  |                           ║
║50                 |                                  X                           ║
║51                 |                                  |                           ║
║52                 |                                            X                 ║
║53                 |                                            |                 ║
║54                 |                                  X                           ║
║55                 |                                  |                           ║
║56  X                                       X                                     ║
║57  |                                       |                                     ║
║58  |                                       |                                     ║
║59  |                                       |                                     ║
║60  |                                       |                                     ║
║61  |                                       |                                     ║
║62  |                                       |                                     ║
║63  |                                       |                                     ║
╚══════════════════════════════════════════════════════════════════════════════════╝

This view is exactly as informative as the first screenshot, just “turned” 90 degrees clockwise. (The “frame” around the display is not part of the output; it is merely there to make the boundaries of the display visible.)

As a technical specification: the output above consists of

2 Assignment

  1. Design a model to represent a piece of music. This may consist of one or more interfaces, abstract classes, concrete classes, enums, etc. Consider carefully what operations it should support, what invariants it assumes, etc.

  2. Document your model.

  3. Implement your model.

  4. Test your model.

  5. Implement the console rendering of your model, so we can visualize your data. We will not be autograding this assignment, but you’d do well to emulate the output above as precisely as possible, as we will be checking it (on models constructed from input files we provide) on future assignments.

Submit any files created in this assignment, along with a text README file explaining your design. Your readme file should give the graders an overview of what the purposes are for every class, interface, etc. that you include in your model, so that they can quickly get a high-level overview of your code. It does not replace the need for proper Javadoc!

3 Grading standards

For this assignment, you will be graded on

4 Submission

Please submit your homework to https://cs3500.ccs.neu.edu/ by the above deadline. Then be sure to complete your self evaluation by its due date.

1You also may not personally know much about musical notation or theory. That is not actually an impediment to implementing these assignments: just be careful and methodical about your design, based on the information here.

2This is the so-called “chromatic scale”. Other musical systems use a five-pitch-per-octave, or pentatonic, scale (common in Asian music); others use twenty-four (common in Slavic music); still other systems forego obvious note names entirely (common in African music).

3So named because it’s roughly in the middle of most people’s speaking voices.