Expand All Collapse All


Display
Should I use StdPicture.setRGB() or StdPicture.setARGB()?
To display pictures without transparency (which is the only case you need to handle in this assignment), setRGB() is recommended. Note that setting the alpha channel value to fully opaque is equivalent, however: setRGB(col, row, r, g, b) is equivalent to setARGB(col, row, 255, r, g, b).
How do I create a "blank" image of prescribed dimensions?
Use StdPicture.init(width, height): this method initializes an image with the corresponding dimensions where every pixel is black (i.e., whose red, green and blue color levels are all 0).
Anonymize
How do I read from StdIn with newlines (rather than any whitespace) as separators?
The StdIn documentation lists all of the methods available in the library. In particular, StdIn.readLine() reads every character until the next line.
How can I recover the individual values in a line of a CSV file?
The s.split(t) method returns an array containing all strings divided by the substring t. For example, "a: b:cd:e".split(":") returns the String array ["a", " b", "cd", "e"].
(You don't need to know what a regular expression is for the purposes of this assignment. But if you're curious, they arise in the theory of formal languages and are quite useful in practice -- if you've ever gotten a warning due to a mistyped email, you've seen them in the wild!)
Transpose
What are "ticks" in a MIDI file?
Ticks measure time in MIDI, and are the smallest unit with which to do so. If a MIDI file has the same tempo throughout, ticks can be converted to beats dividing by 48: beats = ticks / 48.
Fugue
What are "ticks" in a MIDI file?
Ticks measure time in MIDI, and are the smallest unit with which to do so. If a MIDI file has the same tempo throughout, ticks can be converted to beats dividing by 48: beats = ticks / 48. (And they can be converted into multiples of StdMidi.THIRTYSECOND_NOTE by dividing by 384.)
I know comparing double values with == is, in general, risky. Is it OK to do in this assignment?
Yes. The reason it is safe in this particular setting (but not elsewhere) is that 0.125, the value of StdMidi.THIRTYSECOND_NOTE, can be represented exactly as a double -- and so can integer multiples of \(0.125 = 1/8\). This would not be the case for notes with duration of, say, a quarter note triplet (\(4/3\) beats), since \(4/3\) cannot be exactly represented as a double.