DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

Musical Staff

Introduction

In this assignment you will add a musical staff to the project. The musical staff will consist of a set of notes, and the instrument that will be used to render the staff into an audio track.

There will also be some updates to existing classes, and the addition of a staff note, that contains the note information we have already created, an the position in the staff where the note begins.

Syntax in the .score file for staff

This format was designed to be read using the C++ standard library’s >> operator. All values are whitespace delimited. By context, your code should be able to determine whether the next value is a std::string or a double.

TBA

Sample STAFF record

STAFF staff-name instrument-name
  0 qC2
  0.25 wBb9
END-STAFF

Notes on the ScoreReader::readStaff method

Notes on the ScoreReader::readScore method

Notes on the ScoreWriter::getDurationLetter method

Number String
1.0/16.0 “s”
1.0/8.0 “e”
1.0/4.0 “q”
1.0/2.0 “h”
1.0/1.0 “w”

Notes on the ScoreWriter::formatNote method

Notes on the ScoreWriter::writeStaffNote method

Notes on the ScoreWriter::writeStaff method

Notes on MusicalStaff::getDurationInWholeNotes

Notes on MusicalStaff::render

Assignment

Here are the new commands that are required in the score editor program for this assignment. Previous commands are still required.

Command Prefixable? Function Description

TBA

Example Session

$ ./program-score-editor/score_editor 
TBA
Choice? quit

The output file: demo.score.

Programming Requirements

Update library-audiofiles/AudioTrack.{h,cpp}

We will add to the AudioTrack class by allowing it to add values from another AudioTrack object, at a given position in the track. This is the basic operation that will allow us to make an audio track from multiple notes.

AudioTrack Class

This class stores digital audio information for one track of sound.

Data Members:

No changes.

public Methods:

Create library-score/StaffNote.{h,cpp}

StaffNote Class

This class will represent a note in a staff, including the position in the staff when the note begins.

protected Data Members:

public Methods:

Free Functions:

Create library-score/MusicalStaff.{h,cpp}

MusicalStaff Class

This class will represent a staff, with an instrument and a list of staff notes.

protected Data Members:

public Methods:

Free Functions:

Update library-score-io/ScoreReader.{h,cpp}

We will update the ScoreReader class by adding the ability to read a staff.

ScoreReader Class

This class will eventually read all of the information for a piece of music from the .score file format.

Data Members:

No data members are required.

public Methods:

Update library-score-io/ScoreWriter.{h,cpp}

We will update the ScoreWrite class by adding the ability to write a staff.

ScoreWriter Class

This class will eventually write all of the information for a piece of music from the .score file format.

Data Members:

No data members are required.

public Methods:

Additional Documentation

Grading Instructions

To receive credit for this assignment:

Extra Challenges (Not Required)

TBA

Last Updated 04/11/2025