samples
is an array,
System.out.println(samples)
doesn't print the elements of the array.
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.
A.wav
and AMajorScale.wav
sound like
the originals when reversed?StdAudio.read()
first converts the audio to monaural,
so you need not worry about that here.
args
is an array of strings. As with any array, you
can get its length with args.length
.
StdAudio
, it will clip them (round them to +1 or –1).
SynthA.wav
and InvertedSynthA.wav
even though they both make sounds when played individually. What's going on?charAt()
method.
boolean
in a \( 2 \times 3 \) grid individually?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 }
.
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.
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.
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'
.
boolean[][][]
, and why do we use this type? Is there such a thing as a int[][][][][][]
or a String[][][][][][][][]
?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[][][]
.