|
|||||||||
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. A sample can be made to wrap an AudioFile and provide intelligent buffered access to the data. 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 | |
---|---|
javax.sound.sampled.AudioFileFormat |
audioFileFormat
|
java.io.File |
file
|
boolean |
finished
|
float |
length
Length of the file in milliseconds |
int |
nChannels
The number of channels. |
long |
nFrames
The total number of frames. |
long |
nTotalFramesRead
|
boolean |
trace
Advanced Trace the open, closing, and resetting of this audio file. |
java.net.URL |
url
|
Constructor Summary | |
---|---|
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()
|
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 |
---|
public java.io.File file
public java.net.URL url
public javax.sound.sampled.AudioFileFormat audioFileFormat
public int nChannels
public long nFrames
public float length
public long nTotalFramesRead
public boolean finished
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.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 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 |