If you've been paying close attention you've probably realized that the NOTE language can do things that the MUS language can't do. Look at this NOTE program:
It plays two notes that overlap in time. What fun is melody without harmony?
Let's add the ability to play harmonies to the MUS language. We already
'seq' operator, now let's add the
'seq' means to play
left and then play
'par' operator means to play
left and also play
Here's a C major chord in the new MUS.
Before we extend our compiler to the new language, we have to be a bit careful. When adding a feature we always have to ask, how does the new feature interact with all the existing features?
One tricky bit of interaction is defining when songs end. If there
can be multiple notes playing and ending at different times, when does the whole song end?
We need to know this for the
'seq' operator. The
needs to know when
left ends in order to know when to start
To write a compiler for the new MUS language to NOTE, I would recommend
first figuring out
endTime like before. Then use that helper function to write
Write a function
compile that compiles MUS songs that can contain
into NOTE songs.