This class represents a sound, which can be created from a URL, sound file,
resource stream, or digital samples.
Constructor Summary |
SoundClip()
Creates an empty single-channel sound to which samples can be added. |
SoundClip(File file)
Creates a new sound by reading the data from the specified file. |
SoundClip(InputStream in)
Creates a new sound by reading the data from the specified input stream. |
SoundClip(int channels)
Creates an empty sound with the specified number of channels, which
must be 1 for mono and 2 for stereo. |
SoundClip(int[] samples)
Creates a new mono sound from the sample array. |
SoundClip(int[] left,
int[] right)
Creates a new stereo sound from the two sample arrays. |
SoundClip(String name)
Creates a new sound by reading the data from the specified file. |
SoundClip(URL url)
Creates a new sound by reading the data from the specified URL. |
Method Summary |
void |
addSampleData(int sample)
Adds a single sound sample to the end of the sound. |
void |
addSampleData(int[] samples)
Adds the specified samples to the end of the sound. |
void |
addSampleData(int[] left,
int[] right)
Adds the specified samples to the end of the appropriate channels of
the stereo sound. |
void |
addSampleData(int left,
int right)
Adds the specified samples to the end of the appropriate channels of
the stereo sound. |
int |
getChannelCount()
Returns the number of channels. |
double |
getDuration()
Returns the duration of a sound (in seconds). |
int |
getFrameCount()
Returns the number of frames in a sound. |
int |
getFrameIndex()
Returns the current frame index in the sound. |
double |
getFrameRate()
Returns the frame rate of the sound. |
String |
getName()
Returns the name of the sound, which is typically the file name from which it
was read. |
int[] |
getSampleData()
Returns an array of integers corresponding to the samples in the primary
channel of the sound. |
int[] |
getSampleData(int channel)
Returns an array of integers corresponding to the samples in the specified
channel, which is typically represented by LEFT or RIGHT . |
double |
getVolume()
Returns the overall volume setting for the sound, which is a number
between 0 (silent) and 1 (maximum volume). |
int |
intensityToSample(double intensity)
Converts an intensity value between -1.0 and +1.0 into the corresponding
integer sample in the range -32767 and +32767. |
boolean |
isStereo()
Returns true if the sound is recorded in stereo. |
void |
loop()
Plays the sound in a continuous audio loop. |
void |
play()
Plays the sound through the computer's audio system. |
void |
rewind()
Rewinds the sound to the beginning. |
double |
sampleToIntensity(int sample)
Converts an integer sample in the range -32767 and +32767 into a
double between -1.0 and +1.0. |
void |
save(File file)
Writes the sound to the specified File object. |
void |
save(String filename)
Writes a data file containing the specified sound. |
void |
setFrameIndex(int frameIndex)
Sets the current frame index. |
void |
setName(String name)
Sets a name to identify the sound. |
void |
setVolume(double volume)
Sets the overall volume setting for the sound, which is a number
between 0 (silent) and 1 (maximum volume). |
void |
stop()
Stops the playback of the sound. |
String |
toString()
Converts a sound to a string. |