Expand All Collapse All


MusicLoop
Should I use a while loop or a for loop?
Either will get the job done. However, a for loop is more appropriate here since you know how many times the loop should iterate.
How can I crop a WAV file to produce a music loop?
You can use a web app, such as audio-joiner.com. It will also display a schematic of the waveform so that you can see what to crop, such as silence at the beginning or the end of the file. Be sure to save in WAV format.
Where can I download WAV files that would be suitable for music loops?
There are many online resources, including looperman.com. Please keep track of the source and copyright limitations on any files you download.
MajorScale
How do I create a loop to iterate over the notes of a major scale?
Since there are 8 notes in a scale, a loop that goes from 0 to 7 is a fine start. Then, maintain another variable to keep track of the current MIDI note number (e.g., 60). The body of the loop needs to encode the logic for skipping over the MIDI note numbers that are not in the major scale, i.e., the MIDI note number should be incremented by 2 in all iterations except the 3rd and 7th.

A perfectly fine alternative is a loop that goes from root to root + 12.

How should I test and debug my program?
Unless you have a well-trained ear, we suggest printing the MIDI note numbers (instead of playing the corresponding WAV files). Once your program correctly prints the MIDI note numbers, replace the calls to System.out.println() with calls to StdAudio.play().
What are the rules for other musical scales?
Ther are many other musical scales, including minor, chromatic, natural minor, harmonic major, harmonic minor, melodic minor, and major pentatonic. They are defined by similar rules, but different interval patterns. If you're curious, experiment by implementing some of these and comparing the results.
MajorScaleDeluxe
Should I try to write MajorScaleDeluxe.java before MajorScale.java?
No. Write and debug MajorScale.java before moving on to MajorScaleDeluxe.java.
How do I play a scale in both ascending and descending order?
We suggest one loop for playing the notes in ascending order and a second loop for playing the notes in descending order.
How do I create a multi-octave scale?
There are a few reasonable approaches:

Hint: since each octave of a major scale has 7 notes (plus the final note), consider performing arithmetic modulo 7.

SepiaFilter
The StdPicture class does not appear in the textbook. Where can I learn how to use it?
One part of learning how to program is learning how to use a new library. You can learn more about StdPicture by reading its documentation. You will call (a subset of) the following 8 methods:
How can I take a photo and convert it to JPEG format?
You can take the photo with any digital camera that you have, such as a mobile phone camera or a laptop webcam. Depending on how the device is configured, you might have to convert the resulting image to to JPEG format. You can do this using either a built-in app (such as Mac Preview) or an online tool.
Where do the constants in the sepia filter formula come from?
There are different formulas for applying a sepia filter and this is just one. The formula in this exercise appears to have originated from Microsoft.