EXTRA: Extending NOTE with MIDI note numbers
This time we'll modify the NOTE language instead of the MUS language. Suppose we modified the NOTE language to store MIDI note numbers for pitches. Now a chord in NOTE looks like:
The chord would previously have had
g4 as the pitches
but now has 60, 64, and 67.
Here is a chart
of MIDI note numbers and pitches.
compile function to output NOTE songs with MIDI note
compileTto a new function
convertPitchfunction takes pitches (like
c4) and returns a number (like 60).
convertPitch, you need to break apart the pitch letter and the octave. The MIDI number is
12 + 12 * octave + letterPitch. The
letterPitchis 0 for
C, 2 for
D, up to 11 for