|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.beadsproject.beads.data.audiofile.AudioFile
net.beadsproject.beads.data.audiofile.JavaSoundAudioFile
public class JavaSoundAudioFile
Uses javasound to load audio files located on disk or via a URL. KNOWN ISSUE: 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 resaving your .wavs with a different audio util may help.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class net.beadsproject.beads.data.audiofile.AudioFile |
---|
AudioFile.OperationUnsupportedException |
Field Summary | |
---|---|
protected javax.sound.sampled.AudioFileFormat |
audioFileFormat
|
protected javax.sound.sampled.AudioInputStream |
audioInputStream
|
protected java.io.File |
file
|
protected java.net.URL |
url
|
Fields inherited from class net.beadsproject.beads.data.audiofile.AudioFile |
---|
audioFormat, audioInfo, length, name, nFrames, trace |
Constructor Summary | |
---|---|
JavaSoundAudioFile(java.io.InputStream stream)
|
|
JavaSoundAudioFile(java.io.InputStream stream,
int bufferSize)
|
|
JavaSoundAudioFile(java.lang.String filename)
Load an audio file from disk. |
|
JavaSoundAudioFile(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 | |
---|---|
void |
close()
Close the audio file. |
static AudioFormat |
convertJavasoundAudioFormatToBeadsAudioFormat(javax.sound.sampled.AudioFormat af)
|
javax.sound.sampled.AudioFormat |
getDecodedFormat()
|
javax.sound.sampled.AudioFormat |
getEncodedFormat()
|
java.lang.String |
getInformation()
|
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
|
long |
getTimeLengthEstimation(java.util.Map properties)
THIS CODE IS FROM jlGui PlayerUI.java. |
boolean |
isClosed()
Is the file stream closed? |
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 net.beadsproject.beads.data.audiofile.AudioFile |
---|
getFormat, getFrameSize, getLength, getName, getNumChannels, getNumFrames, isOpen, setLength, setNumFrames, setTrace |
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 javax.sound.sampled.AudioFileFormat audioFileFormat
Constructor Detail |
---|
public JavaSoundAudioFile(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 JavaSoundAudioFile(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.
javax.sou
public JavaSoundAudioFile(java.io.InputStream stream) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public JavaSoundAudioFile(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()
reset
in class AudioFile
public void skip(long frames)
skip
in class AudioFile
frames
- Number of frames to skippublic void seek(int frame)
seek
in class AudioFile
frame
- The frame number, relative to the start of the audio data.public void open() throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException
open
in class AudioFile
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
public java.lang.String getInformation()
getInformation
in class AudioFile
public void close() throws java.io.IOException
close
in class AudioFile
java.io.IOException
public boolean isClosed()
isClosed
in class AudioFile
public javax.sound.sampled.AudioFormat getDecodedFormat()
public javax.sound.sampled.AudioFormat getEncodedFormat()
public int read(byte[] buffer)
read
in class AudioFile
buffer
- A buffer to fill.
public int read(float[][] buffer)
read
in class AudioFile
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 java.util.Map<java.lang.String,java.lang.Object> getProperties()
getProperties
in class AudioFile
public long getTimeLengthEstimation(java.util.Map properties)
public static AudioFormat convertJavasoundAudioFormatToBeadsAudioFormat(javax.sound.sampled.AudioFormat af)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |