Problem G
Musical Notation
There are many types of languages, all used for different purposes. People communicate using natural languages like English and Spanish, program with formal languages like C++ and Perl, and compose music with musical notation. Let’s consider musical notation, which is typically a sequence of notes of specified pitches and durations. Computers can best represent these sequences using numbers and letters, such as
C C D E C E D2 C C D E C2 B2 C C D E F E D C B g A B C2 C2
which is a simple rendition of the song ‘Yankee Doodle’. The
notes are chosen from a through g and A through G. A note without a number indicates it is held for a
duration of one beat; the number
Input
The input for your program consists of two lines. The first
line has an integer
Output
For each song, print a text-based representation on one
staff. Each staff should have the following format: a
G: F: ---------------------------------------------------------- E: D: ---------------------------------------------------------- C: B: ---------------------------------------------------------- A: g: ---------------------------------------------------------- f: e: ---------------------------------------------------------- d: c: b: a: ----------------------------------------------------------
For each song’s note, print a single asterisk on a line (or between lines) indicating its pitch. Use one asterisk for the default duration, two asterisks for notes twice as long, three asterisks for notes three times as long, etc. Leave a single separating column between each pair of consecutive notes. The staff lines should be only as long as necessary to complete the song. Notes that are between lines (i.e. b-d, f, A, C, E, G) should pad with spaces out to the end the staff lines.
Sample Input 1 | Sample Output 1 |
---|---|
27 C C D E C E D2 C C D E C2 B2 C C D E F E D C B g A B C2 C2 |
G: F: -------------------------------------*-------------------- E: * * * * * D: ----*-------**-----*-------------*-------*---------------- C: * * * * * ** * * * ** ** B: --------------------------**-----------------*-----*------ A: * g: -----------------------------------------------*---------- f: e: ---------------------------------------------------------- d: c: b: a: ---------------------------------------------------------- |
Sample Input 2 | Sample Output 2 |
---|---|
22 e2 e d c2 c2 d2 d f e d c2 g2 g f e2 e2 e d c d e c3 |
G: F: ----------------------------------------------------- E: D: ----------------------------------------------------- C: B: ----------------------------------------------------- A: g: ---------------------------**-*---------------------- f: * * e: **-*----------------*-------------**-**-*-------*---- d: * ** * * * * c: ** ** ** * *** b: a: ----------------------------------------------------- |