The problem: You are to write a class called Music. It should play 3 tunes of 5 to 12 notes. We will write the notes for first tune in class together, but in class, we will not use any loops; you will write the loops. (Hint: foreach loops will work for any number of notes.)

Music in the West is based on octaves of 12 evenly space notes (technically, it is evenly exponential or logarithmic). To go up an octave, or twelve notes, you must double the frequency. The frequency of each individual note is the 12th root of 2.0 ( 12 2 ) greater than the last note. The 12th root of 2.0 is called a HALF step. To go down a HALF step, you divide by the 12th root of 2.0. A FULL step is a HALF step squared or HALF step*HALF step. A typical C-Major scale (Do Re Mi Fa So La Ti Do), skipping the sharp ( ) and flat ( b ) black notes, starts at C5 (523.2 Hz) and follows only the white piano notes with the sequence:

Do C5 523.2 Hz
Re FULL step (D5),
Mi FULL step (E5),
Fa HALF step (F5)
So FULL step (G5)
La FULL step (A5)
Ti FULL step (B5)
Do HALF step (C6)

A flat ( b ) means go down a HALF step, while a sharp ( ) means go up a HALF step. see image.

The notes of your songs or tunes are stored in a 2 and 3-dimensional array song2d[12][2].

1st dimension: Notes 0, 1, 2, 11. Unused notes are set to null or not used.

2nd dimension: Frequency [index 0] and Millisecond Duration [index 1]

double[][] song2d =
null, null, null, null, null, null,
null, null, null, null, null, null //no tune


1st dimension: Songs 0, 1. Unused songs are set to null.

2nd dimension: Notes 0, 1, 2, 11. Unused notes are set to null or not used. You may increase the number of notes, if you wish.

3rd dimension: Frequency [index 0] and Millisecond Duration [index 1]

double[][][] songs3d =
{ null }, //no tunes
{ null }

A pleasant duration for a note is 650 milliseconds or 0.65 or 2/3rds of a second.

Pick two tunes or parts of songs and calculate the frequencies of the notes and set a duration for each note.

In class, we will calculate the five notes from Close Encounters of the Third Kind (Youtube: ), which the aliens used to say hello. The notes are D5, E5, C5, C4, G4.

final double MSEC = 650; //milliseconds (0.65 secs)
final double HALF = Math.pow(2.0, 1/12.0);
final double FULL = HALF * HALF;
double C5 = 523.2;
double D5 = C5 * FULL;
double E5 = C5 * Math.pow(HALF,4); //or =D5 * FULL;

double[][] song2d =
//song2d – Close Encounters FIVE NOTES
{D5,MSEC}, {E5,MSEC}, {C5,MSEC}, null, null
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.