In this chapter, we talk about several kinds of encodings of data (or objects).
Sound objects are encodings of sounds, typically coming from a WAV file.
An object that represents a sample in a sound. The value of a sample is between -32,768 and 32,767 representing the voltage that a microphone would generate at a given instant when recording a sound. The length of the instant is typically either 1/44,100 of a second (for CD-quality sound) or 1/22,050 of a second (for good enough sound on most computers). A SoundSample object remembers what sound it came from, so if you change its value, it knows to go back and change the right sample value in the sound.
Here are the methods used or introduced in this chapter:
Takes a number and returns it as a positive number.
Takes a filename as input, and returns the full path name of the file with the media directory before the filename.
Lets the user pick a file and returns the complete path name as a string.
Takes a directory as input and sets the directory name to be what is added to the passed filename using getMediaPath.
Plays the Sound object it is invoked on, and makes sure that no other sound plays at the exact same time. (Compare two blockingPlay's with two play's right after each other.)
Returns the number of samples in the Sound object it is invoked on.
Returns an array of SoundSample objects for the Sound object it is invoked on.
Takes an index (an integer value), and returns the value of the sample at that index for the Sound object it is invoked on.
Returns the number representing the number of samples in each second for the Sound object it is invoked on.
Plays the Sound object it is invoked on.
setSampleValueAt(int index, int value)
Takes an index, and a value, and sets the value of the sample at the given index in the Sound object it was invoked on to the given value.
Takes a filename (a string) and writes the sound in the Sound object it is invoked on to that file as a WAV file. (Make sure that the filename ends in ".wav" if you want the operating system to treat it right.)
Returns the value for the SoundSample object it is invoked on.
Sets the value for the SoundSample object it is invoked on to be the passed value.