Expand All Collapse All


ReverseSoundWave
How do I print the values in an array?
Write a loop and print each element. Remember that, if samples is an array, System.out.println(samples) doesn't print the elements of the array.
Should I debug by printing the arrays?
That's a good idea, but you probably don't want to print the entire array. Remember, each second of digital audio contains 44,100 samples. Instead, consider just printing the first (and/or last) handful of elements.

Another way to debug is to use the reversed files supplied, such as ReverseHelloWorld.wav, as the inputs to your program. When you reverse a reversed audio file, you get back the original.

Why do reverse notes in A.wav and AMajorScale.wav sound like the originals when reversed?
The notes are created using pure sine waves—they oscillates with the same frequency whether played regularly or in reverse.
What happens with stereo audio files?
The method StdAudio.read() first converts the audio to monaural, so you need not worry about that here.
Superpose
How can my program determine the number of command-line arguments?
The variable args is an array of strings. As with any array, you can get its length with args.length.
Can I assume that all of the audio files are of the same length?
Yes. No need to worry about superposing sound waves of different lengths.
What should I do if the sum of the samples is bigger than +1 (or less than –1)?
Don't worry about it on this assignment. When you send the samples to StdAudio, it will clip them (round them to +1 or –1).
I don't hear any sound when I superpose SynthA.wav and InvertedSynthA.wav even though they both make sounds when played individually. What's going on?
These two sound waves are the same except the samples are inverted (the signs of the corresponding samples are flipped). As a result, even though they sound the same when played individually, they interact with other sound waves differently. In particular, when superposed, these two sound waves perfectly cancel each other out. This idea is the foundation of technologies like noise-cancelling headphones.
BrailleTranscriber
How do I access characters of a string?
Use the charAt() method.
Can I avoid setting each boolean in a \( 2 \times 3 \) grid individually?
Yes: you can use array initializers, like boolean[][] SPACE = { { false, false }, { false, false }, { false, false } }. Note that you can also avoid repeating boolean literals by declaring, e.g., boolean[] NEITHER = { false, false } then boolean[][] SPACE = { NEITHER, NEITHER, NEITHER }.
How should I store the transcription of each character? Do I need to encode each character individually?
Since the transcription table is constant, you should name it accordingly (e.g., BRAILLE_TABLE). You do need to construct 26 boolean[][] grids, but not in 26 separate lines of code: after constructing the first 10 (for the characters A/a through J/j), the structure of the table allows you to fill in the rest (with the exception of W/w) with a for loop.
Do I need to compare each character to both the upper and lowercase versions of a letter in order to transcribe without case sensitivity?
No. You may use text.toUpperCase()/text.toLowerCase() methods of the String class, or Character.toUpperCase(character)/Character.toLowerCase(character); then only checking against either the upper or lowercase characters suffices.
How do I map characters to array indices?
Remember that the char data type supports arithmetic operations (that evaluate to an int), so you may, e.g., write character - 'A' to determine how many Unicode characters away character is to 'A'.
What exactly is a boolean[][][], and why do we use this type? Is there such a thing as a int[][][][][][] or a String[][][][][][][][]?
Every pair of square brackets indicates the type is an array of the type to its left; so a boolean is an array of booleans, a boolean is an array of arrays of booleans, and a boolean[][][] is an array of arrays of arrays (!) of booleans. (And on and on, for any number of pairs of brackets.) Each Braille character is represented by a \(3 \times 2\) grid of booleans: each raised dot is represented by a boolean; each row of the grid is a boolean[] (of length 2); so a Braille character, an array (of length 3) of rows, is a boolean[][]. Finally, Braille text is an array of Braille characters, i.e., a boolean[][][].