public class BufferedSound extends java.lang.Object implements Content
An individual BufferedSound can only be manipulated by one thread at a time. This should not be a problem in practice since, most often, a BufferedSound will be manipulated first and then rendered.
Note: For simplicity, all BufferedSound objects use signed PCM with a 16bit sample size, and a big-endian byte order (i.e., network byte order).
Constructor and Description |
---|
BufferedSound(float sampleRate)
Explicit Value Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addChannel(double[] signal)
Add a channel to this BufferedSound.
|
void |
append(BufferedSound other)
Append a BufferedSound to this BufferedSound.
|
javax.sound.sampled.AudioFormat |
getAudioFormat()
Get the AudioFormat for this BufferedSound.
|
int |
getMicrosecondLength()
Get the length of this BufferedSound in microseconds.
|
int |
getMillisecondLength()
Get the length of this BufferedSound in milliseconds.
|
int |
getNumberOfChannels()
Get the number of channels.
|
int |
getNumberOfSamples()
Get the number of samples (per channel) in this BufferedSound.
|
float |
getSampleRate()
Get the sampling rate for this BufferedSound.
|
java.util.Iterator<double[]> |
getSignals()
Get the signals.
|
boolean |
matches(BufferedSound other)
Compares this BufferedSound object to another.
|
void |
render(javax.sound.sampled.Clip clip)
Render this BufferedSound on the given Clip.
|
public BufferedSound(float sampleRate)
sampleRate
- The sampling rate (in Hz)public void addChannel(double[] signal)
public void append(BufferedSound other)
Note: If the BufferedSound to append does not match this BufferedSound then nothing is done.
other
- The BufferedSound to appendpublic javax.sound.sampled.AudioFormat getAudioFormat()
getAudioFormat
in interface Content
public java.util.Iterator<double[]> getSignals()
Note: It is dangerous to provide access to the signal data since it could be modified in inappropriate ways
public int getMicrosecondLength()
public int getMillisecondLength()
public int getNumberOfChannels()
public int getNumberOfSamples()
public float getSampleRate()
public boolean matches(BufferedSound other)
other
- The BufferedSound to compare to