public class Sound extends java.lang.Object implements java.lang.Iterable<Sample>
Constructor and Description |
---|
Sound()
Create a sound opening a WAV file selected from a dialog.
|
Sound(java.io.File file)
Create a sound from a specified WAV file.
|
Sound(int length)
Create a new empty (all samples 0) sound with specified length
|
Sound(int length,
int sampSize,
int sampRate)
Create a new empty (silent, all samples 0) sound with specified length
(number of samples), sample size (frame size) and sample rate (frame rate)
|
Sound(int length,
Sound like)
Create a new empty (silent, all samples 0) sound with specified length
(number of samples) and same sound parameters as another sound
|
Sound(java.lang.String filePath)
Create a sound from a specified WAV file.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Frees resources associated with the Sound.
|
java.io.File |
getFile()
Returns the file that is associated with this sound or null if there is no
such file.
|
int |
getNumSamples()
Returns the number of samples in the sound.
|
Sample |
getSample(int pos)
Returns the Sample at a particular position in the Sound.
|
int |
getSampleRate()
Returns the sampling (frame) rate for the sound.
|
int |
getSampleSize()
Returns the sample (frame) size for the sound.
|
boolean |
hasNext()
This method returns true if there is at least one more sample that hasn't
been accessed via the default iterator.
|
java.util.Iterator<Sample> |
iterator() |
Sample |
next()
This method returns the next sample in the sound.
|
void |
play()
This method plays the sound.
|
void |
save()
This method saves the sound to a file chosen from a dialog.
|
void |
save(java.io.File to)
This method saves the sound to a specified file.
|
void |
save(java.lang.String to)
This method saves the sound to a specified file
|
public Sound()
public Sound(java.io.File file)
file
- the file descriptor for the WAV file.public Sound(java.lang.String filePath)
filePath
- the directory and the file name of the file.public Sound(int length, int sampSize, int sampRate)
length
- int number of samplessampSize
- int sample size (in bytes 1-4)sampRate
- int sample rate (in samples/second)public Sound(int length, Sound like)
length
- int number of sampleslike
- Sound sound parameters to mimicpublic Sound(int length)
length
- number of samplespublic void play()
public void save(java.io.File to)
to
- the file (descriptor) to write topublic void save(java.lang.String to)
to
- the file name of the file to write topublic void save()
public void close()
public java.io.File getFile()
public Sample getSample(int pos)
pos
- position (sample number)public int getSampleSize()
public int getNumSamples()
public int getSampleRate()
public java.util.Iterator<Sample> iterator()
iterator
in interface java.lang.Iterable<Sample>
public boolean hasNext()
public Sample next()