I548/N560 HOMEWORK #2 (revised 8 Sept. 2007) * EVERYONE: PlayMelody_LoopV2.R, at: http://www.informatics.indiana.edu/donbyrd/Teach/RExamplePrograms is an R program that plays a well-known melody -- the beginning of the main theme of "Star Wars" -- but with all notes having the same duration. (1) Modify it to use the correct relative durations, and play at a reasonable tempo. Actually, I'll give full credit for any of three versions. Assuming the melody is in 2/2 or 4/4, the durations are (version C): Pitch: -5 -5 -5 0 7 5 4 2 12 7 Dur: T8th T8th T8th / half half / T8th T8th T8th half quarter Or, leaving out the pickups as I originally did (version B): Pitch: 0 7 5 4 2 12 7 Dur: half half / T8th T8th T8th half quarter My original, inaccurate version was (version A): Pitch: 0 7 5 4 2 12 7 Dur: quarter half T8th T8th T8th / quarter half NB: "T8th" = triplet 8th; "/" = barline. (2) Also, with the loop written this way, there's no need for the variable; get rid of it. For extra credit, do (3) and (4) below. NB: if you do version C, the repeated notes at the beginning will blend into a single longer note unless you do steps (3) and/or (4) below, but don't worry about it. * MUSIC INFORMATICS MAJORS: In addition to the above, modify the program to (3) add a bit of silence after every note, and to (4) get rid of the clicks at the beginning and end of every note; by far the easiest way is with a quick fade in and fade out. Both changes should make the performance slightly less ugly. If that's not enough to keep you busy, for extra credit, also (5) add dynamics -- or substitute an actual musical instrument sample for the sine wave. (You can download free musical instrument samples from the University of Iowa; my "Information Sources for Music Informatics Students" page gives the link.) ------------------------------------------------------------------------------- GRADING RUBRIC Of course it's important that a program do what it's supposed to do, but things aren't as simple as that. It's also important that the code be as straightforward and as easy to understand as possible, (1) because it's amazingly difficult to be sure a program of any complexity will always work by testing it, and (2) because many programs turn out to be useful long after they're written, either as is or, very often, with modifications. Starting with a program that wasn't clearly written in the first place greatly increases the chance of modifications introducing bugs. See the slides on programming (starting with no. 13) in the "R Programming and Digital Audio" slide show. A work: your changes to the program are straightforward and easy to understand. For Music Informatics majors, it does steps (1) thru (4) correctly; for others, it does steps (1) and (2) correctly. B work: either your changes are hard to understand or the program fails to do one required step correctly. C work: your changes are hard to understand _and_ the program fails to do one required step correctly, or your changes are easy to understand but it fails to do two required steps correctly.