|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.beadsproject.beads.data.AudioFile
public class AudioFile
Represents an audio file. Handles loading and format conversion.
AudioFile is generally not used directly. Rather Sample
should be used as it provides many useful features for playing audio files.
NOTE: At the moment certain .wav files will be not be able to be loaded.
This is due to mp3spi recognizing them incorrectly as mp3s.
This will hopefull be fixed in the future, but until then
you can resave your .wavs using a different audio util.
Field Summary | |
---|---|
protected javax.sound.sampled.AudioFileFormat |
audioFileFormat
|
protected javax.sound.sampled.AudioInputStream |
audioInputStream
|
protected java.io.File |
file
|
protected float |
length
Length of the file in milliseconds |
protected java.lang.String |
name
|
protected int |
nChannels
The number of channels. |
protected long |
nFrames
The total number of frames. |
boolean |
trace
Advanced Trace the open, closing, and resetting of this audio file. |
protected java.net.URL |
url
|
Constructor Summary | |
---|---|
AudioFile(java.io.InputStream stream)
|
|
AudioFile(java.io.InputStream stream,
int bufferSize)
|
|
AudioFile(java.lang.String filename)
Load an audio file from disk. |
|
AudioFile(java.lang.String filename,
int bufferSize)
Advanced: Create an input stream from a file, but don't keep more than numBytes of data in memory. |
Method Summary | |
---|---|
int |
byteDepth()
|
void |
close()
Close the audio file. |
javax.sound.sampled.AudioFormat |
getDecodedFormat()
|
javax.sound.sampled.AudioFormat |
getEncodedFormat()
|
java.lang.String |
getName()
|
long |
getTimeLengthEstimation(java.util.Map properties)
THIS CODE IS FROM jlGui PlayerUI.java. |
java.lang.String |
info()
|
boolean |
isClosed()
Is the file stream closed? |
boolean |
isOpen()
Is the file stream open? |
void |
open()
Opens the audio file, ready for data access. |
int |
read(byte[] buffer)
Read bytes directly from the decoded audiofile. |
int |
read(float[][] buffer)
Read decoded audio data in a non-interleaved, Beads-friendly format. |
void |
reset()
Reset the audio input stream. |
void |
seek(int frame)
Seek to a specific frame number. |
void |
skip(long frames)
Skips a number of frames. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.File file
protected java.net.URL url
protected javax.sound.sampled.AudioInputStream audioInputStream
protected java.lang.String name
protected javax.sound.sampled.AudioFileFormat audioFileFormat
protected int nChannels
protected long nFrames
protected float length
public boolean trace
Constructor Detail |
---|
public AudioFile(java.lang.String filename) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
filename
- The name of the file to open.
java.io.IOException
- If the file cannot be found or opened.
javax.sound.sampled.UnsupportedAudioFileException
- If the file is of an unsupported audio type.Sample
public AudioFile(java.lang.String filename, int bufferSize) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
filename
- bufferSize
- The maximum number of bytes the AudioFile can keep in memory.
If it is <0 then the length of the audio file is used.
java.io.IOException
- If the file cannot be found or opened.
javax.sound.sampled.UnsupportedAudioFileException
- If the file is of an unsupported audio type.public AudioFile(java.io.InputStream stream) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public AudioFile(java.io.InputStream stream, int bufferSize) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
Method Detail |
---|
public void reset()
public void skip(long frames)
frames
- Number of frames to skippublic void seek(int frame)
frame
- The frame number, relative to the start of the audio data.public void open() throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
public java.lang.String getName()
public java.lang.String info()
public void close() throws java.io.IOException
java.io.IOException
public boolean isOpen()
public boolean isClosed()
public int byteDepth()
public javax.sound.sampled.AudioFormat getDecodedFormat()
public javax.sound.sampled.AudioFormat getEncodedFormat()
public int read(byte[] buffer)
buffer
- A buffer to fill.
public int read(float[][] buffer)
buffer
- The buffer to fill. After execution buffer[i][j] will contain the sample in channel i, frame j. Buffer has size (numChannels,numFramesRequested).
public long getTimeLengthEstimation(java.util.Map properties)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |