DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

Score Editor

Introduction

We are adding support for envelopes to the score editor program now. This includes user commands to add, edit, and list envelopes. It also includes a command to read a score file that contains waveforms and envelopes.

Future assignments will continue to add functionality to the program.

Syntax in the .score file for an envelope

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.

The ENVELOPE keyword must always be followed by the envelope name and the envelope type.

Below you will see the possible fields that can be present for various envelope types. Note that the parameters, such as DECAY-SECONDS and SUSTAIN-AMPLITUDE, are all optional, and order does not matter. If not specified, then the value set in the default constructor should be left in place. If accidentally specified more than once, the last value should be used.

If there is no ENVELOPE-END keyword, then the envelope is invalid, and should not be added to the score.

ADSR Envelope

ENVELOPE name1 ADSR
  MAXIMUM-AMPLITUDE 0.25
  ATTACK-SECONDS 0.01
  DECAY-SECONDS 0.02
  SUSTAIN-AMPLITUDE 0.5
  RELEASE-SECONDS 0.03
ENVELOPE-END

AD Envelope

ENVELOPE name2 AD
  MAXIMUM-AMPLITUDE 0.25
  ATTACK-SECONDS 0.01
ENVELOPE-END

Other Envelope

If you have other envelope types implemented, please add them to the reader.

Notes on the ScoreReader::readEnvelope method

Assignment

Here are the new commands that are required for this assignment. Previous commands are still required.

Command Prefixable? Function Description
score-read no readScoreUI Read score from file.
score-list-envelopes no listScoreEnvelopesUI List envelopes in the score.
score-add-envelope no addScoreEnvelopeUI Add envelope to the score.
score-edit-envelope no editScoreEnvelopeUI Edit envelope in the score.

Example Session

$ ./program-score-editor/score_editor 
Choice? menu
Options are:
  # - Skip to end of line (comment).
  comment - Skip to end of line (comment).
  echo - Echo back the arguments given.
  help - Display help message.
  menu - Display help message.
  quit - Terminate the program.
  score-add-envelope - Add envelope to the score.
  score-add-waveform - Add waveform to the score.
  score-edit-envelope - Edit envelope in the score.
  score-edit-waveform - Edit waveform in the score.
  score-list-envelopes - List envelopes in the score.
  score-list-waveforms - List waveforms in the score.
  score-read - Read score from file.

Choice? score-add-envelope
Envelope name: adsr1
Envelope type: ADSR
Maximum amplitude: 0.1
Attack seconds: 0.2
Decay seconds: 0.3
Sustain amplitude: 0.4
Release seconds: 0.5
Choice? score-add-envelope
Envelope name: ad1
Envelope type: AD
Maximum amplitude: 0.6
Attack seconds: 0.7
Choice? score-edit-envelope
Envelope name: ad1
Maximum amplitude(0.6): 0.11
Attack seconds(0.7): 0.12
Choice? score-edit-envelope
Envelope name: adsr1
Maximum amplitude(0.1): 0.21
Attack seconds(0.2): 0.22
Decay seconds(0.3): 0.23
Sustain amplitude(0.4): 0.24
Release seconds(0.5): 0.25
Choice? score-list-envelopes
ad1 : ad1 AD 0.11
adsr1 : adsr1 ADSR 0.21
Choice? quit

Programming Requirements

Update library-envelope/Envelope.h

These constants should be used by the ScoreReader, instead of using string literals.

Update library-score/MusicalScore.{h,cpp}

We will add to the MusicalScore class by adding the Envelopes collection. Future assignments will add more to the class.

MusicalScore Class

This class will store all of the information for a piece of music.

Data Members:

public Methods:

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

We will update the ScoreReader class by adding the ability to read Envelope objects. Future assignments will add more to the class.

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-commands/score_editor_aux.{h,cpp}

Commands created for the score editor program will go here. We’ll make a few in this assignment, and add more in future assignments.

Functions:

Additional Documentation

Grading Instructions

To receive credit for this assignment:

Extra Challenges (Not Required)

TBA

Last Updated 03/27/2025