|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsound.AudioBuffer
public class AudioBuffer
An AudioBuffer is a self-describing fragment of audio in memory. It can be read and written in a manner similar to java.io.ByteArrayInputStream and java.io.ByteArrayOutputStream. It knows how to transcode itself from one audio format to another.
GRJ - 11/5/02 - This code can probably be simplifed somewhat, but my initial goal was to break out this functionality. The goal was to make an interface that works. The implementation can be cleaned up in the next version.
Constructor Summary | |
---|---|
AudioBuffer()
|
|
AudioBuffer(javax.sound.sampled.AudioFormat format)
Construct an empty AudioBuffer which will hold data of the specified format. |
|
AudioBuffer(javax.sound.sampled.AudioFormat format,
byte[] audioByteArray)
Construct an AudioBuffer containing audio from the supplied byte array. |
|
AudioBuffer(javax.sound.sampled.AudioInputStream ais)
Construct an AudioBuffer containing audio from the supplied AudioInputStream. |
|
AudioBuffer(java.io.File f)
|
Method Summary | |
---|---|
javax.sound.sampled.AudioInputStream |
getAudioInputStream()
Obtain an AudioInputStream that contains the AudioBuffer's data. |
byte[] |
getBytes()
Obtain a byte array that contains the AudioBuffer's data. |
javax.sound.sampled.Clip |
getClip(javax.sound.sampled.LineListener ll)
|
javax.sound.sampled.AudioFormat.Encoding |
getEncoding()
Get the AudioFormat.Encoding corresponding to the AudioBuffer's audio data. |
javax.sound.sampled.AudioFormat |
getFormat()
Get the audio format of the buffer's data as an AudioFormat object. |
int |
getFrameSize()
Get the frame size (bytes per sample) of the AudioBuffer's data. |
float |
getSampleRate()
Get the sample rate (samples per second) of the AudioBuffer's data. |
javax.sound.sampled.SourceDataLine |
getSourceDataLine()
|
static void |
main(java.lang.String[] args)
|
void |
play()
|
void |
playClip()
|
int |
read(byte[] b,
int off,
int len)
Retrieve data from the buffer. |
void |
transcode(javax.sound.sampled.AudioFormat.Encoding destinationEncoding)
Convert the encoding of the audio in the buffer to the specified encoding. |
void |
write(byte[] b,
int off,
int len)
Add data to the buffer. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AudioBuffer(javax.sound.sampled.AudioFormat format)
public AudioBuffer() throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public AudioBuffer(java.io.File f) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public AudioBuffer(javax.sound.sampled.AudioFormat format, byte[] audioByteArray)
public AudioBuffer(javax.sound.sampled.AudioInputStream ais)
Method Detail |
---|
public javax.sound.sampled.Clip getClip(javax.sound.sampled.LineListener ll) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException, javax.sound.sampled.LineUnavailableException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
javax.sound.sampled.LineUnavailableException
public static void main(java.lang.String[] args)
public javax.sound.sampled.SourceDataLine getSourceDataLine() throws javax.sound.sampled.LineUnavailableException
javax.sound.sampled.LineUnavailableException
public void play()
public void playClip() throws java.io.IOException, javax.sound.sampled.LineUnavailableException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.LineUnavailableException
javax.sound.sampled.UnsupportedAudioFileException
public javax.sound.sampled.AudioFormat.Encoding getEncoding()
public float getSampleRate()
public int getFrameSize()
public javax.sound.sampled.AudioFormat getFormat()
public byte[] getBytes()
public javax.sound.sampled.AudioInputStream getAudioInputStream()
public void transcode(javax.sound.sampled.AudioFormat.Encoding destinationEncoding)
public int read(byte[] b, int off, int len) throws java.io.IOException
java.io.IOException
public void write(byte[] b, int off, int len)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |